<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - src/caffe/util/upgrade_proto.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">src/caffe/util</a> - upgrade_proto.cpp<span style="font-size: 80%;"> (source / <a href="upgrade_proto.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">41</td>
            <td class="headerCovTableEntry">562</td>
            <td class="headerCovTableEntryLo">7.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">13</td>
            <td class="headerCovTableEntry">26</td>
            <td class="headerCovTableEntryLo">50.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #include &lt;google/protobuf/io/coded_stream.h&gt;</a>
<span class="lineNum">       2 </span>            : #include &lt;google/protobuf/io/zero_copy_stream_impl.h&gt;
<span class="lineNum">       3 </span>            : #include &lt;google/protobuf/text_format.h&gt;
<span class="lineNum">       4 </span>            : 
<span class="lineNum">       5 </span>            : #include &lt;boost/filesystem.hpp&gt;
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #include &lt;map&gt;
<span class="lineNum">       8 </span>            : #include &lt;string&gt;
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #include &quot;caffe/common.hpp&quot;
<span class="lineNum">      11 </span>            : #include &quot;caffe/proto/caffe.pb.h&quot;
<span class="lineNum">      12 </span>            : #include &quot;caffe/util/io.hpp&quot;
<span class="lineNum">      13 </span>            : #include &quot;caffe/util/upgrade_proto.hpp&quot;
<span class="lineNum">      14 </span>            : 
<a name="15"><span class="lineNum">      15 </span>            : namespace caffe {</a>
<span class="lineNum">      16 </span>            : 
<span class="lineNum">      17 </span><span class="lineNoCov">          0 : bool NetNeedsUpgrade(const NetParameter&amp; net_param) {</span>
<span class="lineNum">      18 </span><span class="lineNoCov">          0 :   return NetNeedsV0ToV1Upgrade(net_param) || NetNeedsV1ToV2Upgrade(net_param)</span>
<span class="lineNum">      19 </span><span class="lineNoCov">          0 :       || NetNeedsDataUpgrade(net_param) || NetNeedsInputUpgrade(net_param)</span>
<span class="lineNum">      20 </span><span class="lineNoCov">          0 :       || NetNeedsBatchNormUpgrade(net_param);</span>
<a name="21"><span class="lineNum">      21 </span>            : }</a>
<span class="lineNum">      22 </span>            : 
<span class="lineNum">      23 </span><span class="lineCov">          2 : bool UpgradeNetAsNeeded(const string&amp; param_file, NetParameter* param) {</span>
<span class="lineNum">      24 </span>            :   bool success = true;
<span class="lineNum">      25 </span><span class="lineCov">          2 :   if (NetNeedsV0ToV1Upgrade(*param)) {</span>
<span class="lineNum">      26 </span>            :     // NetParameter was specified using the old style (V0LayerParameter); try to
<span class="lineNum">      27 </span>            :     // upgrade it.
<span class="lineNum">      28 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Attempting to upgrade input file specified using deprecated &quot;</span>
<span class="lineNum">      29 </span>            :               &lt;&lt; &quot;V0LayerParameter: &quot; &lt;&lt; param_file;
<span class="lineNum">      30 </span><span class="lineNoCov">          0 :     NetParameter original_param(*param);</span>
<span class="lineNum">      31 </span><span class="lineNoCov">          0 :     if (!UpgradeV0Net(original_param, param)) {</span>
<span class="lineNum">      32 </span>            :       success = false;
<span class="lineNum">      33 </span><span class="lineNoCov">          0 :       LOG(ERROR) &lt;&lt; &quot;Warning: had one or more problems upgrading &quot;</span>
<span class="lineNum">      34 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;V0NetParameter to NetParameter (see above); continuing anyway.&quot;;</span>
<span class="lineNum">      35 </span>            :     } else {
<span class="lineNum">      36 </span><span class="lineNoCov">          0 :       LOG(INFO) &lt;&lt; &quot;Successfully upgraded file specified using deprecated &quot;</span>
<span class="lineNum">      37 </span><span class="lineNoCov">          0 :                 &lt;&lt; &quot;V0LayerParameter&quot;;</span>
<span class="lineNum">      38 </span>            :     }
<span class="lineNum">      39 </span><span class="lineNoCov">          0 :     LOG(WARNING) &lt;&lt; &quot;Note that future Caffe releases will not support &quot;</span>
<span class="lineNum">      40 </span>            :         &lt;&lt; &quot;V0NetParameter; use ./build/tools/upgrade_net_proto_text for &quot;
<span class="lineNum">      41 </span>            :         &lt;&lt; &quot;prototxt and ./build/tools/upgrade_net_proto_binary for model &quot;
<span class="lineNum">      42 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot;weights upgrade this and any other net protos to the new format.&quot;;</span>
<span class="lineNum">      43 </span>            :   }
<span class="lineNum">      44 </span>            :   // NetParameter uses old style data transformation fields; try to upgrade it.
<span class="lineNum">      45 </span><span class="lineCov">          2 :   if (NetNeedsDataUpgrade(*param)) {</span>
<span class="lineNum">      46 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Attempting to upgrade input file specified using deprecated &quot;</span>
<span class="lineNum">      47 </span>            :               &lt;&lt; &quot;transformation parameters: &quot; &lt;&lt; param_file;
<span class="lineNum">      48 </span><span class="lineNoCov">          0 :     UpgradeNetDataTransformation(param);</span>
<span class="lineNum">      49 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Successfully upgraded file specified using deprecated &quot;</span>
<span class="lineNum">      50 </span><span class="lineNoCov">          0 :               &lt;&lt; &quot;data transformation parameters.&quot;;</span>
<span class="lineNum">      51 </span><span class="lineNoCov">          0 :     LOG(WARNING) &lt;&lt; &quot;Note that future Caffe releases will only support &quot;</span>
<span class="lineNum">      52 </span><span class="lineNoCov">          0 :                  &lt;&lt; &quot;transform_param messages for transformation fields.&quot;;</span>
<span class="lineNum">      53 </span>            :   }
<span class="lineNum">      54 </span><span class="lineCov">          2 :   if (NetNeedsV1ToV2Upgrade(*param)) {</span>
<span class="lineNum">      55 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Attempting to upgrade input file specified using deprecated &quot;</span>
<span class="lineNum">      56 </span>            :               &lt;&lt; &quot;V1LayerParameter: &quot; &lt;&lt; param_file;
<span class="lineNum">      57 </span><span class="lineNoCov">          0 :     NetParameter original_param(*param);</span>
<span class="lineNum">      58 </span><span class="lineNoCov">          0 :     if (!UpgradeV1Net(original_param, param)) {</span>
<span class="lineNum">      59 </span>            :       success = false;
<span class="lineNum">      60 </span><span class="lineNoCov">          0 :       LOG(ERROR) &lt;&lt; &quot;Warning: had one or more problems upgrading &quot;</span>
<span class="lineNum">      61 </span><span class="lineNoCov">          0 :                  &lt;&lt; &quot;V1LayerParameter (see above); continuing anyway.&quot;;</span>
<span class="lineNum">      62 </span>            :     } else {
<span class="lineNum">      63 </span><span class="lineNoCov">          0 :       LOG(INFO) &lt;&lt; &quot;Successfully upgraded file specified using deprecated &quot;</span>
<span class="lineNum">      64 </span><span class="lineNoCov">          0 :                 &lt;&lt; &quot;V1LayerParameter&quot;;</span>
<span class="lineNum">      65 </span>            :     }
<span class="lineNum">      66 </span>            :   }
<span class="lineNum">      67 </span>            :   // NetParameter uses old style input fields; try to upgrade it.
<span class="lineNum">      68 </span><span class="lineCov">          2 :   if (NetNeedsInputUpgrade(*param)) {</span>
<span class="lineNum">      69 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Attempting to upgrade input file specified using deprecated &quot;</span>
<span class="lineNum">      70 </span>            :               &lt;&lt; &quot;input fields: &quot; &lt;&lt; param_file;
<span class="lineNum">      71 </span><span class="lineNoCov">          0 :     UpgradeNetInput(param);</span>
<span class="lineNum">      72 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Successfully upgraded file specified using deprecated &quot;</span>
<span class="lineNum">      73 </span><span class="lineNoCov">          0 :               &lt;&lt; &quot;input fields.&quot;;</span>
<span class="lineNum">      74 </span><span class="lineNoCov">          0 :     LOG(WARNING) &lt;&lt; &quot;Note that future Caffe releases will only support &quot;</span>
<span class="lineNum">      75 </span><span class="lineNoCov">          0 :                  &lt;&lt; &quot;input layers and not input fields.&quot;;</span>
<span class="lineNum">      76 </span>            :   }
<span class="lineNum">      77 </span>            :   // NetParameter uses old style batch norm layers; try to upgrade it.
<span class="lineNum">      78 </span><span class="lineCov">          2 :   if (NetNeedsBatchNormUpgrade(*param)) {</span>
<span class="lineNum">      79 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Attempting to upgrade batch norm layers using deprecated &quot;</span>
<span class="lineNum">      80 </span>            :               &lt;&lt; &quot;params: &quot; &lt;&lt; param_file;
<span class="lineNum">      81 </span><span class="lineNoCov">          0 :     UpgradeNetBatchNorm(param);</span>
<span class="lineNum">      82 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Successfully upgraded batch norm layers using deprecated &quot;</span>
<span class="lineNum">      83 </span><span class="lineNoCov">          0 :               &lt;&lt; &quot;params.&quot;;</span>
<span class="lineNum">      84 </span>            :   }
<span class="lineNum">      85 </span><span class="lineCov">          2 :   return success;</span>
<a name="86"><span class="lineNum">      86 </span>            : }</a>
<span class="lineNum">      87 </span>            : 
<span class="lineNum">      88 </span><span class="lineCov">          2 : void ReadNetParamsFromTextFileOrDie(const string&amp; param_file,</span>
<span class="lineNum">      89 </span>            :                                     NetParameter* param) {
<span class="lineNum">      90 </span><span class="lineCov">          4 :   CHECK(ReadProtoFromTextFile(param_file, param))</span>
<span class="lineNum">      91 </span><span class="lineCov">          4 :       &lt;&lt; &quot;Failed to parse NetParameter file: &quot; &lt;&lt; param_file;</span>
<span class="lineNum">      92 </span><span class="lineCov">          2 :   UpgradeNetAsNeeded(param_file, param);</span>
<a name="93"><span class="lineNum">      93 </span><span class="lineCov">          2 : }</span></a>
<span class="lineNum">      94 </span>            : 
<span class="lineNum">      95 </span><span class="lineNoCov">          0 : void ReadNetParamsFromBinaryFileOrDie(const string&amp; param_file,</span>
<span class="lineNum">      96 </span>            :                                       NetParameter* param) {
<span class="lineNum">      97 </span><span class="lineNoCov">          0 :   CHECK(ReadProtoFromBinaryFile(param_file, param))</span>
<span class="lineNum">      98 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Failed to parse NetParameter file: &quot; &lt;&lt; param_file;</span>
<span class="lineNum">      99 </span><span class="lineNoCov">          0 :   UpgradeNetAsNeeded(param_file, param);</span>
<span class="lineNum">     100 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     101 </span>            : 
<span class="lineNum">     102 </span><span class="lineCov">          2 : bool NetNeedsV0ToV1Upgrade(const NetParameter&amp; net_param) {</span>
<span class="lineNum">     103 </span><span class="lineCov">          2 :   for (int i = 0; i &lt; net_param.layers_size(); ++i) {</span>
<span class="lineNum">     104 </span><span class="lineNoCov">          0 :     if (net_param.layers(i).has_layer()) {</span>
<span class="lineNum">     105 </span>            :       return true;
<span class="lineNum">     106 </span>            :     }
<span class="lineNum">     107 </span>            :   }
<span class="lineNum">     108 </span>            :   return false;
<a name="109"><span class="lineNum">     109 </span>            : }</a>
<span class="lineNum">     110 </span>            : 
<span class="lineNum">     111 </span><span class="lineCov">          2 : bool NetNeedsV1ToV2Upgrade(const NetParameter&amp; net_param) {</span>
<span class="lineNum">     112 </span><span class="lineCov">          2 :   return net_param.layers_size() &gt; 0;</span>
<span class="lineNum">     113 </span>            : }
<span class="lineNum">     114 </span>            : 
<span class="lineNum">     115 </span><span class="lineNoCov">          0 : bool UpgradeV0Net(const NetParameter&amp; v0_net_param_padding_layers,</span>
<span class="lineNum">     116 </span>            :                   NetParameter* net_param) {
<span class="lineNum">     117 </span>            :   // First upgrade padding layers to padded conv layers.
<span class="lineNum">     118 </span><span class="lineNoCov">          0 :   NetParameter v0_net_param;</span>
<span class="lineNum">     119 </span><span class="lineNoCov">          0 :   UpgradeV0PaddingLayers(v0_net_param_padding_layers, &amp;v0_net_param);</span>
<span class="lineNum">     120 </span>            :   // Now upgrade layer parameters.
<span class="lineNum">     121 </span>            :   bool is_fully_compatible = true;
<span class="lineNum">     122 </span><span class="lineNoCov">          0 :   net_param-&gt;Clear();</span>
<span class="lineNum">     123 </span><span class="lineNoCov">          0 :   if (v0_net_param.has_name()) {</span>
<span class="lineNum">     124 </span><span class="lineNoCov">          0 :     net_param-&gt;set_name(v0_net_param.name());</span>
<span class="lineNum">     125 </span>            :   }
<span class="lineNum">     126 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v0_net_param.layers_size(); ++i) {</span>
<span class="lineNum">     127 </span>            :     is_fully_compatible &amp;= UpgradeV0LayerParameter(v0_net_param.layers(i),
<span class="lineNum">     128 </span><span class="lineNoCov">          0 :                                                    net_param-&gt;add_layers());</span>
<span class="lineNum">     129 </span>            :   }
<span class="lineNum">     130 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v0_net_param.input_size(); ++i) {</span>
<span class="lineNum">     131 </span>            :     net_param-&gt;add_input(v0_net_param.input(i));
<span class="lineNum">     132 </span>            :   }
<span class="lineNum">     133 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v0_net_param.input_dim_size(); ++i) {</span>
<span class="lineNum">     134 </span>            :     net_param-&gt;add_input_dim(v0_net_param.input_dim(i));
<span class="lineNum">     135 </span>            :   }
<span class="lineNum">     136 </span><span class="lineNoCov">          0 :   if (v0_net_param.has_force_backward()) {</span>
<span class="lineNum">     137 </span>            :     net_param-&gt;set_force_backward(v0_net_param.force_backward());
<span class="lineNum">     138 </span>            :   }
<span class="lineNum">     139 </span><span class="lineNoCov">          0 :   return is_fully_compatible;</span>
<span class="lineNum">     140 </span>            : }
<span class="lineNum">     141 </span>            : 
<span class="lineNum">     142 </span><span class="lineNoCov">          0 : void UpgradeV0PaddingLayers(const NetParameter&amp; param,</span>
<span class="lineNum">     143 </span>            :                             NetParameter* param_upgraded_pad) {
<span class="lineNum">     144 </span>            :   // Copy everything other than the layers from the original param.
<span class="lineNum">     145 </span><span class="lineNoCov">          0 :   param_upgraded_pad-&gt;Clear();</span>
<span class="lineNum">     146 </span><span class="lineNoCov">          0 :   param_upgraded_pad-&gt;CopyFrom(param);</span>
<span class="lineNum">     147 </span>            :   param_upgraded_pad-&gt;clear_layers();
<span class="lineNum">     148 </span>            :   // Figure out which layer each bottom blob comes from.
<span class="lineNum">     149 </span>            :   map&lt;string, int&gt; blob_name_to_last_top_idx;
<span class="lineNum">     150 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; param.input_size(); ++i) {</span>
<span class="lineNum">     151 </span>            :     const string&amp; blob_name = param.input(i);
<span class="lineNum">     152 </span><span class="lineNoCov">          0 :     blob_name_to_last_top_idx[blob_name] = -1;</span>
<span class="lineNum">     153 </span>            :   }
<span class="lineNum">     154 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; param.layers_size(); ++i) {</span>
<span class="lineNum">     155 </span>            :     const V1LayerParameter&amp; layer_connection = param.layers(i);
<span class="lineNum">     156 </span>            :     const V0LayerParameter&amp; layer_param = layer_connection.layer();
<span class="lineNum">     157 </span>            :     // Add the layer to the new net, unless it's a padding layer.
<span class="lineNum">     158 </span><span class="lineNoCov">          0 :     if (layer_param.type() != &quot;padding&quot;) {</span>
<span class="lineNum">     159 </span><span class="lineNoCov">          0 :       param_upgraded_pad-&gt;add_layers()-&gt;CopyFrom(layer_connection);</span>
<span class="lineNum">     160 </span>            :     }
<span class="lineNum">     161 </span><span class="lineNoCov">          0 :     for (int j = 0; j &lt; layer_connection.bottom_size(); ++j) {</span>
<span class="lineNum">     162 </span>            :       const string&amp; blob_name = layer_connection.bottom(j);
<span class="lineNum">     163 </span><span class="lineNoCov">          0 :       if (blob_name_to_last_top_idx.find(blob_name) ==</span>
<span class="lineNum">     164 </span>            :           blob_name_to_last_top_idx.end()) {
<span class="lineNum">     165 </span><span class="lineNoCov">          0 :         LOG(FATAL) &lt;&lt; &quot;Unknown blob input &quot; &lt;&lt; blob_name &lt;&lt; &quot; to layer &quot; &lt;&lt; j;</span>
<span class="lineNum">     166 </span>            :       }
<span class="lineNum">     167 </span><span class="lineNoCov">          0 :       const int top_idx = blob_name_to_last_top_idx[blob_name];</span>
<span class="lineNum">     168 </span><span class="lineNoCov">          0 :       if (top_idx == -1) {</span>
<span class="lineNum">     169 </span>            :         continue;
<span class="lineNum">     170 </span>            :       }
<span class="lineNum">     171 </span>            :       const V1LayerParameter&amp; source_layer = param.layers(top_idx);
<span class="lineNum">     172 </span><span class="lineNoCov">          0 :       if (source_layer.layer().type() == &quot;padding&quot;) {</span>
<span class="lineNum">     173 </span>            :         // This layer has a padding layer as input -- check that it is a conv
<span class="lineNum">     174 </span>            :         // layer or a pooling layer and takes only one input.  Also check that
<span class="lineNum">     175 </span>            :         // the padding layer input has only one input and one output.  Other
<span class="lineNum">     176 </span>            :         // cases have undefined behavior in Caffe.
<span class="lineNum">     177 </span><span class="lineNoCov">          0 :         CHECK((layer_param.type() == &quot;conv&quot;) || (layer_param.type() == &quot;pool&quot;))</span>
<span class="lineNum">     178 </span>            :             &lt;&lt; &quot;Padding layer input to &quot;
<span class="lineNum">     179 </span>            :             &quot;non-convolutional / non-pooling layer type &quot;
<span class="lineNum">     180 </span><span class="lineNoCov">          0 :             &lt;&lt; layer_param.type();</span>
<span class="lineNum">     181 </span><span class="lineNoCov">          0 :         CHECK_EQ(layer_connection.bottom_size(), 1)</span>
<span class="lineNum">     182 </span><span class="lineNoCov">          0 :             &lt;&lt; &quot;Conv Layer takes a single blob as input.&quot;;</span>
<span class="lineNum">     183 </span><span class="lineNoCov">          0 :         CHECK_EQ(source_layer.bottom_size(), 1)</span>
<span class="lineNum">     184 </span><span class="lineNoCov">          0 :             &lt;&lt; &quot;Padding Layer takes a single blob as input.&quot;;</span>
<span class="lineNum">     185 </span><span class="lineNoCov">          0 :         CHECK_EQ(source_layer.top_size(), 1)</span>
<span class="lineNum">     186 </span><span class="lineNoCov">          0 :             &lt;&lt; &quot;Padding Layer produces a single blob as output.&quot;;</span>
<span class="lineNum">     187 </span><span class="lineNoCov">          0 :         int layer_index = param_upgraded_pad-&gt;layers_size() - 1;</span>
<span class="lineNum">     188 </span>            :         param_upgraded_pad-&gt;mutable_layers(layer_index)-&gt;mutable_layer()
<span class="lineNum">     189 </span><span class="lineNoCov">          0 :             -&gt;set_pad(source_layer.layer().pad());</span>
<span class="lineNum">     190 </span>            :         param_upgraded_pad-&gt;mutable_layers(layer_index)
<span class="lineNum">     191 </span>            :             -&gt;set_bottom(j, source_layer.bottom(0));
<span class="lineNum">     192 </span>            :       }
<span class="lineNum">     193 </span>            :     }
<span class="lineNum">     194 </span><span class="lineNoCov">          0 :     for (int j = 0; j &lt; layer_connection.top_size(); ++j) {</span>
<span class="lineNum">     195 </span>            :       const string&amp; blob_name = layer_connection.top(j);
<span class="lineNum">     196 </span><span class="lineNoCov">          0 :       blob_name_to_last_top_idx[blob_name] = i;</span>
<span class="lineNum">     197 </span>            :     }
<span class="lineNum">     198 </span>            :   }
<span class="lineNum">     199 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     200 </span>            : 
<span class="lineNum">     201 </span><span class="lineNoCov">          0 : bool UpgradeV0LayerParameter(const V1LayerParameter&amp; v0_layer_connection,</span>
<span class="lineNum">     202 </span>            :                              V1LayerParameter* layer_param) {
<span class="lineNum">     203 </span>            :   bool is_fully_compatible = true;
<span class="lineNum">     204 </span><span class="lineNoCov">          0 :   layer_param-&gt;Clear();</span>
<span class="lineNum">     205 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v0_layer_connection.bottom_size(); ++i) {</span>
<span class="lineNum">     206 </span>            :     layer_param-&gt;add_bottom(v0_layer_connection.bottom(i));
<span class="lineNum">     207 </span>            :   }
<span class="lineNum">     208 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v0_layer_connection.top_size(); ++i) {</span>
<span class="lineNum">     209 </span>            :     layer_param-&gt;add_top(v0_layer_connection.top(i));
<span class="lineNum">     210 </span>            :   }
<span class="lineNum">     211 </span><span class="lineNoCov">          0 :   if (v0_layer_connection.has_layer()) {</span>
<span class="lineNum">     212 </span>            :     const V0LayerParameter&amp; v0_layer_param = v0_layer_connection.layer();
<span class="lineNum">     213 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_name()) {</span>
<span class="lineNum">     214 </span><span class="lineNoCov">          0 :       layer_param-&gt;set_name(v0_layer_param.name());</span>
<span class="lineNum">     215 </span>            :     }
<span class="lineNum">     216 </span>            :     const string&amp; type = v0_layer_param.type();
<span class="lineNum">     217 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_type()) {</span>
<span class="lineNum">     218 </span><span class="lineNoCov">          0 :       layer_param-&gt;set_type(UpgradeV0LayerType(type));</span>
<span class="lineNum">     219 </span>            :     }
<span class="lineNum">     220 </span><span class="lineNoCov">          0 :     for (int i = 0; i &lt; v0_layer_param.blobs_size(); ++i) {</span>
<span class="lineNum">     221 </span><span class="lineNoCov">          0 :       layer_param-&gt;add_blobs()-&gt;CopyFrom(v0_layer_param.blobs(i));</span>
<span class="lineNum">     222 </span>            :     }
<span class="lineNum">     223 </span><span class="lineNoCov">          0 :     for (int i = 0; i &lt; v0_layer_param.blobs_lr_size(); ++i) {</span>
<span class="lineNum">     224 </span>            :       layer_param-&gt;add_blobs_lr(v0_layer_param.blobs_lr(i));
<span class="lineNum">     225 </span>            :     }
<span class="lineNum">     226 </span><span class="lineNoCov">          0 :     for (int i = 0; i &lt; v0_layer_param.weight_decay_size(); ++i) {</span>
<span class="lineNum">     227 </span>            :       layer_param-&gt;add_weight_decay(v0_layer_param.weight_decay(i));
<span class="lineNum">     228 </span>            :     }
<span class="lineNum">     229 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_num_output()) {</span>
<span class="lineNum">     230 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     231 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_convolution_param()-&gt;set_num_output(</span>
<span class="lineNum">     232 </span>            :             v0_layer_param.num_output());
<span class="lineNum">     233 </span><span class="lineNoCov">          0 :       } else if (type == &quot;innerproduct&quot;) {</span>
<span class="lineNum">     234 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_inner_product_param()-&gt;set_num_output(</span>
<span class="lineNum">     235 </span>            :             v0_layer_param.num_output());
<span class="lineNum">     236 </span>            :       } else {
<span class="lineNum">     237 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter num_output for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     238 </span>            :         is_fully_compatible = false;
<span class="lineNum">     239 </span>            :       }
<span class="lineNum">     240 </span>            :     }
<span class="lineNum">     241 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_biasterm()) {</span>
<span class="lineNum">     242 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     243 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_convolution_param()-&gt;set_bias_term(</span>
<span class="lineNum">     244 </span>            :             v0_layer_param.biasterm());
<span class="lineNum">     245 </span><span class="lineNoCov">          0 :       } else if (type == &quot;innerproduct&quot;) {</span>
<span class="lineNum">     246 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_inner_product_param()-&gt;set_bias_term(</span>
<span class="lineNum">     247 </span>            :             v0_layer_param.biasterm());
<span class="lineNum">     248 </span>            :       } else {
<span class="lineNum">     249 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter biasterm for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     250 </span>            :         is_fully_compatible = false;
<span class="lineNum">     251 </span>            :       }
<span class="lineNum">     252 </span>            :     }
<span class="lineNum">     253 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_weight_filler()) {</span>
<span class="lineNum">     254 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     255 </span>            :         layer_param-&gt;mutable_convolution_param()-&gt;
<span class="lineNum">     256 </span><span class="lineNoCov">          0 :             mutable_weight_filler()-&gt;CopyFrom(v0_layer_param.weight_filler());</span>
<span class="lineNum">     257 </span><span class="lineNoCov">          0 :       } else if (type == &quot;innerproduct&quot;) {</span>
<span class="lineNum">     258 </span>            :         layer_param-&gt;mutable_inner_product_param()-&gt;
<span class="lineNum">     259 </span><span class="lineNoCov">          0 :             mutable_weight_filler()-&gt;CopyFrom(v0_layer_param.weight_filler());</span>
<span class="lineNum">     260 </span>            :       } else {
<span class="lineNum">     261 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter weight_filler for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     262 </span>            :         is_fully_compatible = false;
<span class="lineNum">     263 </span>            :       }
<span class="lineNum">     264 </span>            :     }
<span class="lineNum">     265 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_bias_filler()) {</span>
<span class="lineNum">     266 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     267 </span>            :         layer_param-&gt;mutable_convolution_param()-&gt;
<span class="lineNum">     268 </span><span class="lineNoCov">          0 :             mutable_bias_filler()-&gt;CopyFrom(v0_layer_param.bias_filler());</span>
<span class="lineNum">     269 </span><span class="lineNoCov">          0 :       } else if (type == &quot;innerproduct&quot;) {</span>
<span class="lineNum">     270 </span>            :         layer_param-&gt;mutable_inner_product_param()-&gt;
<span class="lineNum">     271 </span><span class="lineNoCov">          0 :             mutable_bias_filler()-&gt;CopyFrom(v0_layer_param.bias_filler());</span>
<span class="lineNum">     272 </span>            :       } else {
<span class="lineNum">     273 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter bias_filler for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     274 </span>            :         is_fully_compatible = false;
<span class="lineNum">     275 </span>            :       }
<span class="lineNum">     276 </span>            :     }
<span class="lineNum">     277 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_pad()) {</span>
<span class="lineNum">     278 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     279 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_convolution_param()-&gt;add_pad(v0_layer_param.pad());</span>
<span class="lineNum">     280 </span><span class="lineNoCov">          0 :       } else if (type == &quot;pool&quot;) {</span>
<span class="lineNum">     281 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_pooling_param()-&gt;set_pad(v0_layer_param.pad());</span>
<span class="lineNum">     282 </span>            :       } else {
<span class="lineNum">     283 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter pad for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     284 </span>            :         is_fully_compatible = false;
<span class="lineNum">     285 </span>            :       }
<span class="lineNum">     286 </span>            :     }
<span class="lineNum">     287 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_kernelsize()) {</span>
<span class="lineNum">     288 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     289 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_convolution_param()-&gt;add_kernel_size(</span>
<span class="lineNum">     290 </span>            :             v0_layer_param.kernelsize());
<span class="lineNum">     291 </span><span class="lineNoCov">          0 :       } else if (type == &quot;pool&quot;) {</span>
<span class="lineNum">     292 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_pooling_param()-&gt;set_kernel_size(</span>
<span class="lineNum">     293 </span>            :             v0_layer_param.kernelsize());
<span class="lineNum">     294 </span>            :       } else {
<span class="lineNum">     295 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter kernelsize for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     296 </span>            :         is_fully_compatible = false;
<span class="lineNum">     297 </span>            :       }
<span class="lineNum">     298 </span>            :     }
<span class="lineNum">     299 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_group()) {</span>
<span class="lineNum">     300 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     301 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_convolution_param()-&gt;set_group(</span>
<span class="lineNum">     302 </span>            :             v0_layer_param.group());
<span class="lineNum">     303 </span>            :       } else {
<span class="lineNum">     304 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter group for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     305 </span>            :         is_fully_compatible = false;
<span class="lineNum">     306 </span>            :       }
<span class="lineNum">     307 </span>            :     }
<span class="lineNum">     308 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_stride()) {</span>
<span class="lineNum">     309 </span><span class="lineNoCov">          0 :       if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     310 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_convolution_param()-&gt;add_stride(</span>
<span class="lineNum">     311 </span>            :             v0_layer_param.stride());
<span class="lineNum">     312 </span><span class="lineNoCov">          0 :       } else if (type == &quot;pool&quot;) {</span>
<span class="lineNum">     313 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_pooling_param()-&gt;set_stride(</span>
<span class="lineNum">     314 </span>            :             v0_layer_param.stride());
<span class="lineNum">     315 </span>            :       } else {
<span class="lineNum">     316 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter stride for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     317 </span>            :         is_fully_compatible = false;
<span class="lineNum">     318 </span>            :       }
<span class="lineNum">     319 </span>            :     }
<span class="lineNum">     320 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_pool()) {</span>
<span class="lineNum">     321 </span><span class="lineNoCov">          0 :       if (type == &quot;pool&quot;) {</span>
<span class="lineNum">     322 </span>            :         V0LayerParameter_PoolMethod pool = v0_layer_param.pool();
<span class="lineNum">     323 </span><span class="lineNoCov">          0 :         switch (pool) {</span>
<span class="lineNum">     324 </span>            :         case V0LayerParameter_PoolMethod_MAX:
<span class="lineNum">     325 </span><span class="lineNoCov">          0 :           layer_param-&gt;mutable_pooling_param()-&gt;set_pool(</span>
<span class="lineNum">     326 </span>            :               PoolingParameter_PoolMethod_MAX);
<span class="lineNum">     327 </span>            :           break;
<span class="lineNum">     328 </span>            :         case V0LayerParameter_PoolMethod_AVE:
<span class="lineNum">     329 </span><span class="lineNoCov">          0 :           layer_param-&gt;mutable_pooling_param()-&gt;set_pool(</span>
<span class="lineNum">     330 </span>            :               PoolingParameter_PoolMethod_AVE);
<span class="lineNum">     331 </span>            :           break;
<span class="lineNum">     332 </span>            :         case V0LayerParameter_PoolMethod_STOCHASTIC:
<span class="lineNum">     333 </span><span class="lineNoCov">          0 :           layer_param-&gt;mutable_pooling_param()-&gt;set_pool(</span>
<span class="lineNum">     334 </span>            :               PoolingParameter_PoolMethod_STOCHASTIC);
<span class="lineNum">     335 </span>            :           break;
<span class="lineNum">     336 </span>            :         default:
<span class="lineNum">     337 </span><span class="lineNoCov">          0 :           LOG(ERROR) &lt;&lt; &quot;Unknown pool method &quot; &lt;&lt; pool;</span>
<span class="lineNum">     338 </span>            :           is_fully_compatible = false;
<span class="lineNum">     339 </span>            :         }
<span class="lineNum">     340 </span>            :       } else {
<span class="lineNum">     341 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter pool for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     342 </span>            :         is_fully_compatible = false;
<span class="lineNum">     343 </span>            :       }
<span class="lineNum">     344 </span>            :     }
<span class="lineNum">     345 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_dropout_ratio()) {</span>
<span class="lineNum">     346 </span><span class="lineNoCov">          0 :       if (type == &quot;dropout&quot;) {</span>
<span class="lineNum">     347 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_dropout_param()-&gt;set_dropout_ratio(</span>
<span class="lineNum">     348 </span>            :             v0_layer_param.dropout_ratio());
<span class="lineNum">     349 </span>            :       } else {
<span class="lineNum">     350 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter dropout_ratio for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     351 </span>            :         is_fully_compatible = false;
<span class="lineNum">     352 </span>            :       }
<span class="lineNum">     353 </span>            :     }
<span class="lineNum">     354 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_local_size()) {</span>
<span class="lineNum">     355 </span><span class="lineNoCov">          0 :       if (type == &quot;lrn&quot;) {</span>
<span class="lineNum">     356 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_lrn_param()-&gt;set_local_size(</span>
<span class="lineNum">     357 </span>            :             v0_layer_param.local_size());
<span class="lineNum">     358 </span>            :       } else {
<span class="lineNum">     359 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter local_size for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     360 </span>            :         is_fully_compatible = false;
<span class="lineNum">     361 </span>            :       }
<span class="lineNum">     362 </span>            :     }
<span class="lineNum">     363 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_alpha()) {</span>
<span class="lineNum">     364 </span><span class="lineNoCov">          0 :       if (type == &quot;lrn&quot;) {</span>
<span class="lineNum">     365 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_lrn_param()-&gt;set_alpha(v0_layer_param.alpha());</span>
<span class="lineNum">     366 </span>            :       } else {
<span class="lineNum">     367 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter alpha for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     368 </span>            :         is_fully_compatible = false;
<span class="lineNum">     369 </span>            :       }
<span class="lineNum">     370 </span>            :     }
<span class="lineNum">     371 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_beta()) {</span>
<span class="lineNum">     372 </span><span class="lineNoCov">          0 :       if (type == &quot;lrn&quot;) {</span>
<span class="lineNum">     373 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_lrn_param()-&gt;set_beta(v0_layer_param.beta());</span>
<span class="lineNum">     374 </span>            :       } else {
<span class="lineNum">     375 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter beta for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     376 </span>            :         is_fully_compatible = false;
<span class="lineNum">     377 </span>            :       }
<span class="lineNum">     378 </span>            :     }
<span class="lineNum">     379 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_k()) {</span>
<span class="lineNum">     380 </span><span class="lineNoCov">          0 :       if (type == &quot;lrn&quot;) {</span>
<span class="lineNum">     381 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_lrn_param()-&gt;set_k(v0_layer_param.k());</span>
<span class="lineNum">     382 </span>            :       } else {
<span class="lineNum">     383 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter k for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     384 </span>            :         is_fully_compatible = false;
<span class="lineNum">     385 </span>            :       }
<span class="lineNum">     386 </span>            :     }
<span class="lineNum">     387 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_source()) {</span>
<span class="lineNum">     388 </span><span class="lineNoCov">          0 :       if (type == &quot;data&quot;) {</span>
<span class="lineNum">     389 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_data_param()-&gt;set_source(v0_layer_param.source());</span>
<span class="lineNum">     390 </span><span class="lineNoCov">          0 :       } else if (type == &quot;hdf5_data&quot;) {</span>
<span class="lineNum">     391 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_hdf5_data_param()-&gt;set_source(</span>
<span class="lineNum">     392 </span><span class="lineNoCov">          0 :             v0_layer_param.source());</span>
<span class="lineNum">     393 </span><span class="lineNoCov">          0 :       } else if (type == &quot;images&quot;) {</span>
<span class="lineNum">     394 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_image_data_param()-&gt;set_source(</span>
<span class="lineNum">     395 </span><span class="lineNoCov">          0 :             v0_layer_param.source());</span>
<span class="lineNum">     396 </span><span class="lineNoCov">          0 :       } else if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     397 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_source(</span>
<span class="lineNum">     398 </span><span class="lineNoCov">          0 :             v0_layer_param.source());</span>
<span class="lineNum">     399 </span><span class="lineNoCov">          0 :       } else if (type == &quot;infogain_loss&quot;) {</span>
<span class="lineNum">     400 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_infogain_loss_param()-&gt;set_source(</span>
<span class="lineNum">     401 </span><span class="lineNoCov">          0 :             v0_layer_param.source());</span>
<span class="lineNum">     402 </span>            :       } else {
<span class="lineNum">     403 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter source for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     404 </span>            :         is_fully_compatible = false;
<span class="lineNum">     405 </span>            :       }
<span class="lineNum">     406 </span>            :     }
<span class="lineNum">     407 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_scale()) {</span>
<span class="lineNum">     408 </span>            :       layer_param-&gt;mutable_transform_param()-&gt;
<span class="lineNum">     409 </span><span class="lineNoCov">          0 :           set_scale(v0_layer_param.scale());</span>
<span class="lineNum">     410 </span>            :     }
<span class="lineNum">     411 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_meanfile()) {</span>
<span class="lineNum">     412 </span>            :       layer_param-&gt;mutable_transform_param()-&gt;
<span class="lineNum">     413 </span><span class="lineNoCov">          0 :           set_mean_file(v0_layer_param.meanfile());</span>
<span class="lineNum">     414 </span>            :     }
<span class="lineNum">     415 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_batchsize()) {</span>
<span class="lineNum">     416 </span><span class="lineNoCov">          0 :       if (type == &quot;data&quot;) {</span>
<span class="lineNum">     417 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_data_param()-&gt;set_batch_size(</span>
<span class="lineNum">     418 </span>            :             v0_layer_param.batchsize());
<span class="lineNum">     419 </span><span class="lineNoCov">          0 :       } else if (type == &quot;hdf5_data&quot;) {</span>
<span class="lineNum">     420 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_hdf5_data_param()-&gt;set_batch_size(</span>
<span class="lineNum">     421 </span>            :             v0_layer_param.batchsize());
<span class="lineNum">     422 </span><span class="lineNoCov">          0 :       } else if (type == &quot;images&quot;) {</span>
<span class="lineNum">     423 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_image_data_param()-&gt;set_batch_size(</span>
<span class="lineNum">     424 </span>            :             v0_layer_param.batchsize());
<span class="lineNum">     425 </span><span class="lineNoCov">          0 :       } else if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     426 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_batch_size(</span>
<span class="lineNum">     427 </span>            :             v0_layer_param.batchsize());
<span class="lineNum">     428 </span>            :       } else {
<span class="lineNum">     429 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter batchsize for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     430 </span>            :         is_fully_compatible = false;
<span class="lineNum">     431 </span>            :       }
<span class="lineNum">     432 </span>            :     }
<span class="lineNum">     433 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_cropsize()) {</span>
<span class="lineNum">     434 </span>            :       layer_param-&gt;mutable_transform_param()-&gt;
<span class="lineNum">     435 </span><span class="lineNoCov">          0 :           set_crop_size(v0_layer_param.cropsize());</span>
<span class="lineNum">     436 </span>            :     }
<span class="lineNum">     437 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_mirror()) {</span>
<span class="lineNum">     438 </span>            :       layer_param-&gt;mutable_transform_param()-&gt;
<span class="lineNum">     439 </span><span class="lineNoCov">          0 :           set_mirror(v0_layer_param.mirror());</span>
<span class="lineNum">     440 </span>            :     }
<span class="lineNum">     441 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_rand_skip()) {</span>
<span class="lineNum">     442 </span><span class="lineNoCov">          0 :       if (type == &quot;data&quot;) {</span>
<span class="lineNum">     443 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_data_param()-&gt;set_rand_skip(</span>
<span class="lineNum">     444 </span>            :             v0_layer_param.rand_skip());
<span class="lineNum">     445 </span><span class="lineNoCov">          0 :       } else if (type == &quot;images&quot;) {</span>
<span class="lineNum">     446 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_image_data_param()-&gt;set_rand_skip(</span>
<span class="lineNum">     447 </span>            :             v0_layer_param.rand_skip());
<span class="lineNum">     448 </span>            :       } else {
<span class="lineNum">     449 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter rand_skip for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     450 </span>            :         is_fully_compatible = false;
<span class="lineNum">     451 </span>            :       }
<span class="lineNum">     452 </span>            :     }
<span class="lineNum">     453 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_shuffle_images()) {</span>
<span class="lineNum">     454 </span><span class="lineNoCov">          0 :       if (type == &quot;images&quot;) {</span>
<span class="lineNum">     455 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_image_data_param()-&gt;set_shuffle(</span>
<span class="lineNum">     456 </span>            :             v0_layer_param.shuffle_images());
<span class="lineNum">     457 </span>            :       } else {
<span class="lineNum">     458 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter shuffle for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     459 </span>            :         is_fully_compatible = false;
<span class="lineNum">     460 </span>            :       }
<span class="lineNum">     461 </span>            :     }
<span class="lineNum">     462 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_new_height()) {</span>
<span class="lineNum">     463 </span><span class="lineNoCov">          0 :       if (type == &quot;images&quot;) {</span>
<span class="lineNum">     464 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_image_data_param()-&gt;set_new_height(</span>
<span class="lineNum">     465 </span>            :             v0_layer_param.new_height());
<span class="lineNum">     466 </span>            :       } else {
<span class="lineNum">     467 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter new_height for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     468 </span>            :         is_fully_compatible = false;
<span class="lineNum">     469 </span>            :       }
<span class="lineNum">     470 </span>            :     }
<span class="lineNum">     471 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_new_width()) {</span>
<span class="lineNum">     472 </span><span class="lineNoCov">          0 :       if (type == &quot;images&quot;) {</span>
<span class="lineNum">     473 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_image_data_param()-&gt;set_new_width(</span>
<span class="lineNum">     474 </span>            :             v0_layer_param.new_width());
<span class="lineNum">     475 </span>            :       } else {
<span class="lineNum">     476 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter new_width for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     477 </span>            :         is_fully_compatible = false;
<span class="lineNum">     478 </span>            :       }
<span class="lineNum">     479 </span>            :     }
<span class="lineNum">     480 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_concat_dim()) {</span>
<span class="lineNum">     481 </span><span class="lineNoCov">          0 :       if (type == &quot;concat&quot;) {</span>
<span class="lineNum">     482 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_concat_param()-&gt;set_concat_dim(</span>
<span class="lineNum">     483 </span>            :             v0_layer_param.concat_dim());
<span class="lineNum">     484 </span>            :       } else {
<span class="lineNum">     485 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter concat_dim for layer type &quot; &lt;&lt; type;</span>
<span class="lineNum">     486 </span>            :         is_fully_compatible = false;
<span class="lineNum">     487 </span>            :       }
<span class="lineNum">     488 </span>            :     }
<span class="lineNum">     489 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_det_fg_threshold()) {</span>
<span class="lineNum">     490 </span><span class="lineNoCov">          0 :       if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     491 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_fg_threshold(</span>
<span class="lineNum">     492 </span>            :             v0_layer_param.det_fg_threshold());
<span class="lineNum">     493 </span>            :       } else {
<span class="lineNum">     494 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter det_fg_threshold for layer type &quot;</span>
<span class="lineNum">     495 </span>            :                    &lt;&lt; type;
<span class="lineNum">     496 </span>            :         is_fully_compatible = false;
<span class="lineNum">     497 </span>            :       }
<span class="lineNum">     498 </span>            :     }
<span class="lineNum">     499 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_det_bg_threshold()) {</span>
<span class="lineNum">     500 </span><span class="lineNoCov">          0 :       if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     501 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_bg_threshold(</span>
<span class="lineNum">     502 </span>            :             v0_layer_param.det_bg_threshold());
<span class="lineNum">     503 </span>            :       } else {
<span class="lineNum">     504 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter det_bg_threshold for layer type &quot;</span>
<span class="lineNum">     505 </span>            :                    &lt;&lt; type;
<span class="lineNum">     506 </span>            :         is_fully_compatible = false;
<span class="lineNum">     507 </span>            :       }
<span class="lineNum">     508 </span>            :     }
<span class="lineNum">     509 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_det_fg_fraction()) {</span>
<span class="lineNum">     510 </span><span class="lineNoCov">          0 :       if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     511 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_fg_fraction(</span>
<span class="lineNum">     512 </span>            :             v0_layer_param.det_fg_fraction());
<span class="lineNum">     513 </span>            :       } else {
<span class="lineNum">     514 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter det_fg_fraction for layer type &quot;</span>
<span class="lineNum">     515 </span>            :                    &lt;&lt; type;
<span class="lineNum">     516 </span>            :         is_fully_compatible = false;
<span class="lineNum">     517 </span>            :       }
<span class="lineNum">     518 </span>            :     }
<span class="lineNum">     519 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_det_context_pad()) {</span>
<span class="lineNum">     520 </span><span class="lineNoCov">          0 :       if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     521 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_context_pad(</span>
<span class="lineNum">     522 </span>            :             v0_layer_param.det_context_pad());
<span class="lineNum">     523 </span>            :       } else {
<span class="lineNum">     524 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter det_context_pad for layer type &quot;</span>
<span class="lineNum">     525 </span>            :                    &lt;&lt; type;
<span class="lineNum">     526 </span>            :         is_fully_compatible = false;
<span class="lineNum">     527 </span>            :       }
<span class="lineNum">     528 </span>            :     }
<span class="lineNum">     529 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_det_crop_mode()) {</span>
<span class="lineNum">     530 </span><span class="lineNoCov">          0 :       if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     531 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_window_data_param()-&gt;set_crop_mode(</span>
<span class="lineNum">     532 </span><span class="lineNoCov">          0 :             v0_layer_param.det_crop_mode());</span>
<span class="lineNum">     533 </span>            :       } else {
<span class="lineNum">     534 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter det_crop_mode for layer type &quot;</span>
<span class="lineNum">     535 </span>            :                    &lt;&lt; type;
<span class="lineNum">     536 </span>            :         is_fully_compatible = false;
<span class="lineNum">     537 </span>            :       }
<span class="lineNum">     538 </span>            :     }
<span class="lineNum">     539 </span><span class="lineNoCov">          0 :     if (v0_layer_param.has_hdf5_output_param()) {</span>
<span class="lineNum">     540 </span><span class="lineNoCov">          0 :       if (type == &quot;hdf5_output&quot;) {</span>
<span class="lineNum">     541 </span><span class="lineNoCov">          0 :         layer_param-&gt;mutable_hdf5_output_param()-&gt;CopyFrom(</span>
<span class="lineNum">     542 </span><span class="lineNoCov">          0 :             v0_layer_param.hdf5_output_param());</span>
<span class="lineNum">     543 </span>            :       } else {
<span class="lineNum">     544 </span><span class="lineNoCov">          0 :         LOG(ERROR) &lt;&lt; &quot;Unknown parameter hdf5_output_param for layer type &quot;</span>
<span class="lineNum">     545 </span>            :                    &lt;&lt; type;
<span class="lineNum">     546 </span>            :         is_fully_compatible = false;
<span class="lineNum">     547 </span>            :       }
<span class="lineNum">     548 </span>            :     }
<span class="lineNum">     549 </span>            :   }
<span class="lineNum">     550 </span><span class="lineNoCov">          0 :   return is_fully_compatible;</span>
<a name="551"><span class="lineNum">     551 </span>            : }</a>
<span class="lineNum">     552 </span>            : 
<span class="lineNum">     553 </span><span class="lineNoCov">          0 : V1LayerParameter_LayerType UpgradeV0LayerType(const string&amp; type) {</span>
<span class="lineNum">     554 </span><span class="lineNoCov">          0 :   if (type == &quot;accuracy&quot;) {</span>
<span class="lineNum">     555 </span>            :     return V1LayerParameter_LayerType_ACCURACY;
<span class="lineNum">     556 </span><span class="lineNoCov">          0 :   } else if (type == &quot;bnll&quot;) {</span>
<span class="lineNum">     557 </span>            :     return V1LayerParameter_LayerType_BNLL;
<span class="lineNum">     558 </span><span class="lineNoCov">          0 :   } else if (type == &quot;concat&quot;) {</span>
<span class="lineNum">     559 </span>            :     return V1LayerParameter_LayerType_CONCAT;
<span class="lineNum">     560 </span><span class="lineNoCov">          0 :   } else if (type == &quot;conv&quot;) {</span>
<span class="lineNum">     561 </span>            :     return V1LayerParameter_LayerType_CONVOLUTION;
<span class="lineNum">     562 </span><span class="lineNoCov">          0 :   } else if (type == &quot;data&quot;) {</span>
<span class="lineNum">     563 </span>            :     return V1LayerParameter_LayerType_DATA;
<span class="lineNum">     564 </span><span class="lineNoCov">          0 :   } else if (type == &quot;dropout&quot;) {</span>
<span class="lineNum">     565 </span>            :     return V1LayerParameter_LayerType_DROPOUT;
<span class="lineNum">     566 </span><span class="lineNoCov">          0 :   } else if (type == &quot;euclidean_loss&quot;) {</span>
<span class="lineNum">     567 </span>            :     return V1LayerParameter_LayerType_EUCLIDEAN_LOSS;
<span class="lineNum">     568 </span><span class="lineNoCov">          0 :   } else if (type == &quot;flatten&quot;) {</span>
<span class="lineNum">     569 </span>            :     return V1LayerParameter_LayerType_FLATTEN;
<span class="lineNum">     570 </span><span class="lineNoCov">          0 :   } else if (type == &quot;hdf5_data&quot;) {</span>
<span class="lineNum">     571 </span>            :     return V1LayerParameter_LayerType_HDF5_DATA;
<span class="lineNum">     572 </span><span class="lineNoCov">          0 :   } else if (type == &quot;hdf5_output&quot;) {</span>
<span class="lineNum">     573 </span>            :     return V1LayerParameter_LayerType_HDF5_OUTPUT;
<span class="lineNum">     574 </span><span class="lineNoCov">          0 :   } else if (type == &quot;im2col&quot;) {</span>
<span class="lineNum">     575 </span>            :     return V1LayerParameter_LayerType_IM2COL;
<span class="lineNum">     576 </span><span class="lineNoCov">          0 :   } else if (type == &quot;images&quot;) {</span>
<span class="lineNum">     577 </span>            :     return V1LayerParameter_LayerType_IMAGE_DATA;
<span class="lineNum">     578 </span><span class="lineNoCov">          0 :   } else if (type == &quot;infogain_loss&quot;) {</span>
<span class="lineNum">     579 </span>            :     return V1LayerParameter_LayerType_INFOGAIN_LOSS;
<span class="lineNum">     580 </span><span class="lineNoCov">          0 :   } else if (type == &quot;innerproduct&quot;) {</span>
<span class="lineNum">     581 </span>            :     return V1LayerParameter_LayerType_INNER_PRODUCT;
<span class="lineNum">     582 </span><span class="lineNoCov">          0 :   } else if (type == &quot;lrn&quot;) {</span>
<span class="lineNum">     583 </span>            :     return V1LayerParameter_LayerType_LRN;
<span class="lineNum">     584 </span><span class="lineNoCov">          0 :   } else if (type == &quot;multinomial_logistic_loss&quot;) {</span>
<span class="lineNum">     585 </span>            :     return V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS;
<span class="lineNum">     586 </span><span class="lineNoCov">          0 :   } else if (type == &quot;pool&quot;) {</span>
<span class="lineNum">     587 </span>            :     return V1LayerParameter_LayerType_POOLING;
<span class="lineNum">     588 </span><span class="lineNoCov">          0 :   } else if (type == &quot;relu&quot;) {</span>
<span class="lineNum">     589 </span>            :     return V1LayerParameter_LayerType_RELU;
<span class="lineNum">     590 </span><span class="lineNoCov">          0 :   } else if (type == &quot;sigmoid&quot;) {</span>
<span class="lineNum">     591 </span>            :     return V1LayerParameter_LayerType_SIGMOID;
<span class="lineNum">     592 </span><span class="lineNoCov">          0 :   } else if (type == &quot;softmax&quot;) {</span>
<span class="lineNum">     593 </span>            :     return V1LayerParameter_LayerType_SOFTMAX;
<span class="lineNum">     594 </span><span class="lineNoCov">          0 :   } else if (type == &quot;softmax_loss&quot;) {</span>
<span class="lineNum">     595 </span>            :     return V1LayerParameter_LayerType_SOFTMAX_LOSS;
<span class="lineNum">     596 </span><span class="lineNoCov">          0 :   } else if (type == &quot;split&quot;) {</span>
<span class="lineNum">     597 </span>            :     return V1LayerParameter_LayerType_SPLIT;
<span class="lineNum">     598 </span><span class="lineNoCov">          0 :   } else if (type == &quot;tanh&quot;) {</span>
<span class="lineNum">     599 </span>            :     return V1LayerParameter_LayerType_TANH;
<span class="lineNum">     600 </span><span class="lineNoCov">          0 :   } else if (type == &quot;window_data&quot;) {</span>
<span class="lineNum">     601 </span>            :     return V1LayerParameter_LayerType_WINDOW_DATA;
<span class="lineNum">     602 </span>            :   } else {
<span class="lineNum">     603 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Unknown layer name: &quot; &lt;&lt; type;</span>
<span class="lineNum">     604 </span>            :     return V1LayerParameter_LayerType_NONE;
<span class="lineNum">     605 </span>            :   }
<span class="lineNum">     606 </span>            : }
<span class="lineNum">     607 </span>            : 
<span class="lineNum">     608 </span><span class="lineCov">          2 : bool NetNeedsDataUpgrade(const NetParameter&amp; net_param) {</span>
<span class="lineNum">     609 </span><span class="lineCov">          2 :   for (int i = 0; i &lt; net_param.layers_size(); ++i) {</span>
<span class="lineNum">     610 </span><span class="lineNoCov">          0 :     if (net_param.layers(i).type() == V1LayerParameter_LayerType_DATA) {</span>
<span class="lineNum">     611 </span><span class="lineNoCov">          0 :       DataParameter layer_param = net_param.layers(i).data_param();</span>
<span class="lineNum">     612 </span><span class="lineNoCov">          0 :       if (layer_param.has_scale()) { return true; }</span>
<span class="lineNum">     613 </span><span class="lineNoCov">          0 :       if (layer_param.has_mean_file()) { return true; }</span>
<span class="lineNum">     614 </span><span class="lineNoCov">          0 :       if (layer_param.has_crop_size()) { return true; }</span>
<span class="lineNum">     615 </span><span class="lineNoCov">          0 :       if (layer_param.has_mirror()) { return true; }</span>
<span class="lineNum">     616 </span>            :     }
<span class="lineNum">     617 </span><span class="lineNoCov">          0 :     if (net_param.layers(i).type() == V1LayerParameter_LayerType_IMAGE_DATA) {</span>
<span class="lineNum">     618 </span><span class="lineNoCov">          0 :       ImageDataParameter layer_param = net_param.layers(i).image_data_param();</span>
<span class="lineNum">     619 </span><span class="lineNoCov">          0 :       if (layer_param.has_scale()) { return true; }</span>
<span class="lineNum">     620 </span><span class="lineNoCov">          0 :       if (layer_param.has_mean_file()) { return true; }</span>
<span class="lineNum">     621 </span><span class="lineNoCov">          0 :       if (layer_param.has_crop_size()) { return true; }</span>
<span class="lineNum">     622 </span><span class="lineNoCov">          0 :       if (layer_param.has_mirror()) { return true; }</span>
<span class="lineNum">     623 </span>            :     }
<span class="lineNum">     624 </span><span class="lineNoCov">          0 :     if (net_param.layers(i).type() == V1LayerParameter_LayerType_WINDOW_DATA) {</span>
<span class="lineNum">     625 </span><span class="lineNoCov">          0 :       WindowDataParameter layer_param = net_param.layers(i).window_data_param();</span>
<span class="lineNum">     626 </span><span class="lineNoCov">          0 :       if (layer_param.has_scale()) { return true; }</span>
<span class="lineNum">     627 </span><span class="lineNoCov">          0 :       if (layer_param.has_mean_file()) { return true; }</span>
<span class="lineNum">     628 </span><span class="lineNoCov">          0 :       if (layer_param.has_crop_size()) { return true; }</span>
<span class="lineNum">     629 </span><span class="lineNoCov">          0 :       if (layer_param.has_mirror()) { return true; }</span>
<span class="lineNum">     630 </span>            :     }
<span class="lineNum">     631 </span>            :   }
<span class="lineNum">     632 </span>            :   return false;
<span class="lineNum">     633 </span>            : }
<span class="lineNum">     634 </span>            : 
<span class="lineNum">     635 </span>            : #define CONVERT_LAYER_TRANSFORM_PARAM(TYPE, Name, param_name) \
<span class="lineNum">     636 </span>            :   do { \
<span class="lineNum">     637 </span>            :     if (net_param-&gt;layers(i).type() == V1LayerParameter_LayerType_##TYPE) { \
<span class="lineNum">     638 </span>            :       Name##Parameter* layer_param = \
<span class="lineNum">     639 </span>            :           net_param-&gt;mutable_layers(i)-&gt;mutable_##param_name##_param(); \
<span class="lineNum">     640 </span>            :       TransformationParameter* transform_param = \
<span class="lineNum">     641 </span>            :           net_param-&gt;mutable_layers(i)-&gt;mutable_transform_param(); \
<span class="lineNum">     642 </span>            :       if (layer_param-&gt;has_scale()) { \
<span class="lineNum">     643 </span>            :         transform_param-&gt;set_scale(layer_param-&gt;scale()); \
<span class="lineNum">     644 </span>            :         layer_param-&gt;clear_scale(); \
<span class="lineNum">     645 </span>            :       } \
<span class="lineNum">     646 </span>            :       if (layer_param-&gt;has_mean_file()) { \
<span class="lineNum">     647 </span>            :         transform_param-&gt;set_mean_file(layer_param-&gt;mean_file()); \
<span class="lineNum">     648 </span>            :         layer_param-&gt;clear_mean_file(); \
<span class="lineNum">     649 </span>            :       } \
<span class="lineNum">     650 </span>            :       if (layer_param-&gt;has_crop_size()) { \
<span class="lineNum">     651 </span>            :         transform_param-&gt;set_crop_size(layer_param-&gt;crop_size()); \
<span class="lineNum">     652 </span>            :         layer_param-&gt;clear_crop_size(); \
<span class="lineNum">     653 </span>            :       } \
<span class="lineNum">     654 </span>            :       if (layer_param-&gt;has_mirror()) { \
<span class="lineNum">     655 </span>            :         transform_param-&gt;set_mirror(layer_param-&gt;mirror()); \
<span class="lineNum">     656 </span>            :         layer_param-&gt;clear_mirror(); \
<span class="lineNum">     657 </span>            :       } \
<span class="lineNum">     658 </span>            :     } \
<span class="lineNum">     659 </span>            :   } while (0)
<span class="lineNum">     660 </span>            : 
<span class="lineNum">     661 </span><span class="lineNoCov">          0 : void UpgradeNetDataTransformation(NetParameter* net_param) {</span>
<span class="lineNum">     662 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; net_param-&gt;layers_size(); ++i) {</span>
<span class="lineNum">     663 </span><span class="lineNoCov">          0 :     CONVERT_LAYER_TRANSFORM_PARAM(DATA, Data, data);</span>
<span class="lineNum">     664 </span><span class="lineNoCov">          0 :     CONVERT_LAYER_TRANSFORM_PARAM(IMAGE_DATA, ImageData, image_data);</span>
<span class="lineNum">     665 </span><span class="lineNoCov">          0 :     CONVERT_LAYER_TRANSFORM_PARAM(WINDOW_DATA, WindowData, window_data);</span>
<span class="lineNum">     666 </span>            :   }
<a name="667"><span class="lineNum">     667 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     668 </span>            : 
<span class="lineNum">     669 </span><span class="lineNoCov">          0 : bool UpgradeV1Net(const NetParameter&amp; v1_net_param, NetParameter* net_param) {</span>
<span class="lineNum">     670 </span><span class="lineNoCov">          0 :   if (v1_net_param.layer_size() &gt; 0) {</span>
<span class="lineNum">     671 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Refusing to upgrade inconsistent NetParameter input; &quot;</span>
<span class="lineNum">     672 </span>            :         &lt;&lt; &quot;the definition includes both 'layer' and 'layers' fields. &quot;
<span class="lineNum">     673 </span>            :         &lt;&lt; &quot;The current format defines 'layer' fields with string type like &quot;
<span class="lineNum">     674 </span>            :         &lt;&lt; &quot;layer { type: 'Layer' ... } and not layers { type: LAYER ... }. &quot;
<span class="lineNum">     675 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot;Manually switch the definition to 'layer' format to continue.&quot;;</span>
<span class="lineNum">     676 </span>            :   }
<span class="lineNum">     677 </span>            :   bool is_fully_compatible = true;
<span class="lineNum">     678 </span><span class="lineNoCov">          0 :   net_param-&gt;CopyFrom(v1_net_param);</span>
<span class="lineNum">     679 </span>            :   net_param-&gt;clear_layers();
<span class="lineNum">     680 </span>            :   net_param-&gt;clear_layer();
<span class="lineNum">     681 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_net_param.layers_size(); ++i) {</span>
<span class="lineNum">     682 </span><span class="lineNoCov">          0 :     if (!UpgradeV1LayerParameter(v1_net_param.layers(i),</span>
<span class="lineNum">     683 </span>            :                                  net_param-&gt;add_layer())) {
<span class="lineNum">     684 </span><span class="lineNoCov">          0 :       LOG(ERROR) &lt;&lt; &quot;Upgrade of input layer &quot; &lt;&lt; i &lt;&lt; &quot; failed.&quot;;</span>
<span class="lineNum">     685 </span>            :       is_fully_compatible = false;
<span class="lineNum">     686 </span>            :     }
<span class="lineNum">     687 </span>            :   }
<span class="lineNum">     688 </span><span class="lineNoCov">          0 :   return is_fully_compatible;</span>
<span class="lineNum">     689 </span>            : }
<span class="lineNum">     690 </span>            : 
<span class="lineNum">     691 </span><span class="lineNoCov">          0 : bool UpgradeV1LayerParameter(const V1LayerParameter&amp; v1_layer_param,</span>
<span class="lineNum">     692 </span>            :                              LayerParameter* layer_param) {
<span class="lineNum">     693 </span><span class="lineNoCov">          0 :   layer_param-&gt;Clear();</span>
<span class="lineNum">     694 </span>            :   bool is_fully_compatible = true;
<span class="lineNum">     695 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.bottom_size(); ++i) {</span>
<span class="lineNum">     696 </span>            :     layer_param-&gt;add_bottom(v1_layer_param.bottom(i));
<span class="lineNum">     697 </span>            :   }
<span class="lineNum">     698 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.top_size(); ++i) {</span>
<span class="lineNum">     699 </span>            :     layer_param-&gt;add_top(v1_layer_param.top(i));
<span class="lineNum">     700 </span>            :   }
<span class="lineNum">     701 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_name()) {</span>
<span class="lineNum">     702 </span><span class="lineNoCov">          0 :     layer_param-&gt;set_name(v1_layer_param.name());</span>
<span class="lineNum">     703 </span>            :   }
<span class="lineNum">     704 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.include_size(); ++i) {</span>
<span class="lineNum">     705 </span><span class="lineNoCov">          0 :     layer_param-&gt;add_include()-&gt;CopyFrom(v1_layer_param.include(i));</span>
<span class="lineNum">     706 </span>            :   }
<span class="lineNum">     707 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.exclude_size(); ++i) {</span>
<span class="lineNum">     708 </span><span class="lineNoCov">          0 :     layer_param-&gt;add_exclude()-&gt;CopyFrom(v1_layer_param.exclude(i));</span>
<span class="lineNum">     709 </span>            :   }
<span class="lineNum">     710 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_type()) {</span>
<span class="lineNum">     711 </span><span class="lineNoCov">          0 :     layer_param-&gt;set_type(UpgradeV1LayerType(v1_layer_param.type()));</span>
<span class="lineNum">     712 </span>            :   }
<span class="lineNum">     713 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.blobs_size(); ++i) {</span>
<span class="lineNum">     714 </span><span class="lineNoCov">          0 :     layer_param-&gt;add_blobs()-&gt;CopyFrom(v1_layer_param.blobs(i));</span>
<span class="lineNum">     715 </span>            :   }
<span class="lineNum">     716 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.param_size(); ++i) {</span>
<span class="lineNum">     717 </span><span class="lineNoCov">          0 :     while (layer_param-&gt;param_size() &lt;= i) { layer_param-&gt;add_param(); }</span>
<span class="lineNum">     718 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_param(i)-&gt;set_name(v1_layer_param.param(i));</span>
<span class="lineNum">     719 </span>            :   }
<span class="lineNum">     720 </span>            :   ParamSpec_DimCheckMode mode;
<span class="lineNum">     721 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.blob_share_mode_size(); ++i) {</span>
<span class="lineNum">     722 </span><span class="lineNoCov">          0 :     while (layer_param-&gt;param_size() &lt;= i) { layer_param-&gt;add_param(); }</span>
<span class="lineNum">     723 </span><span class="lineNoCov">          0 :     switch (v1_layer_param.blob_share_mode(i)) {</span>
<span class="lineNum">     724 </span>            :     case V1LayerParameter_DimCheckMode_STRICT:
<span class="lineNum">     725 </span>            :       mode = ParamSpec_DimCheckMode_STRICT;
<span class="lineNum">     726 </span>            :       break;
<span class="lineNum">     727 </span>            :     case V1LayerParameter_DimCheckMode_PERMISSIVE:
<span class="lineNum">     728 </span>            :       mode = ParamSpec_DimCheckMode_PERMISSIVE;
<span class="lineNum">     729 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">     730 </span>            :     default:
<span class="lineNum">     731 </span><span class="lineNoCov">          0 :       LOG(FATAL) &lt;&lt; &quot;Unknown blob_share_mode: &quot;</span>
<span class="lineNum">     732 </span><span class="lineNoCov">          0 :                  &lt;&lt; v1_layer_param.blob_share_mode(i);</span>
<span class="lineNum">     733 </span>            :       break;
<span class="lineNum">     734 </span>            :     }
<span class="lineNum">     735 </span>            :     layer_param-&gt;mutable_param(i)-&gt;set_share_mode(mode);
<span class="lineNum">     736 </span>            :   }
<span class="lineNum">     737 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.blobs_lr_size(); ++i) {</span>
<span class="lineNum">     738 </span><span class="lineNoCov">          0 :     while (layer_param-&gt;param_size() &lt;= i) { layer_param-&gt;add_param(); }</span>
<span class="lineNum">     739 </span>            :     layer_param-&gt;mutable_param(i)-&gt;set_lr_mult(v1_layer_param.blobs_lr(i));
<span class="lineNum">     740 </span>            :   }
<span class="lineNum">     741 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.weight_decay_size(); ++i) {</span>
<span class="lineNum">     742 </span><span class="lineNoCov">          0 :     while (layer_param-&gt;param_size() &lt;= i) { layer_param-&gt;add_param(); }</span>
<span class="lineNum">     743 </span>            :     layer_param-&gt;mutable_param(i)-&gt;set_decay_mult(
<span class="lineNum">     744 </span>            :         v1_layer_param.weight_decay(i));
<span class="lineNum">     745 </span>            :   }
<span class="lineNum">     746 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; v1_layer_param.loss_weight_size(); ++i) {</span>
<span class="lineNum">     747 </span>            :     layer_param-&gt;add_loss_weight(v1_layer_param.loss_weight(i));
<span class="lineNum">     748 </span>            :   }
<span class="lineNum">     749 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_accuracy_param()) {</span>
<span class="lineNum">     750 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_accuracy_param()-&gt;CopyFrom(</span>
<span class="lineNum">     751 </span><span class="lineNoCov">          0 :         v1_layer_param.accuracy_param());</span>
<span class="lineNum">     752 </span>            :   }
<span class="lineNum">     753 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_argmax_param()) {</span>
<span class="lineNum">     754 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_argmax_param()-&gt;CopyFrom(</span>
<span class="lineNum">     755 </span><span class="lineNoCov">          0 :         v1_layer_param.argmax_param());</span>
<span class="lineNum">     756 </span>            :   }
<span class="lineNum">     757 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_concat_param()) {</span>
<span class="lineNum">     758 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_concat_param()-&gt;CopyFrom(</span>
<span class="lineNum">     759 </span><span class="lineNoCov">          0 :         v1_layer_param.concat_param());</span>
<span class="lineNum">     760 </span>            :   }
<span class="lineNum">     761 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_contrastive_loss_param()) {</span>
<span class="lineNum">     762 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_contrastive_loss_param()-&gt;CopyFrom(</span>
<span class="lineNum">     763 </span><span class="lineNoCov">          0 :         v1_layer_param.contrastive_loss_param());</span>
<span class="lineNum">     764 </span>            :   }
<span class="lineNum">     765 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_convolution_param()) {</span>
<span class="lineNum">     766 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_convolution_param()-&gt;CopyFrom(</span>
<span class="lineNum">     767 </span><span class="lineNoCov">          0 :         v1_layer_param.convolution_param());</span>
<span class="lineNum">     768 </span>            :   }
<span class="lineNum">     769 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_data_param()) {</span>
<span class="lineNum">     770 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_data_param()-&gt;CopyFrom(</span>
<span class="lineNum">     771 </span><span class="lineNoCov">          0 :         v1_layer_param.data_param());</span>
<span class="lineNum">     772 </span>            :   }
<span class="lineNum">     773 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_dropout_param()) {</span>
<span class="lineNum">     774 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_dropout_param()-&gt;CopyFrom(</span>
<span class="lineNum">     775 </span><span class="lineNoCov">          0 :         v1_layer_param.dropout_param());</span>
<span class="lineNum">     776 </span>            :   }
<span class="lineNum">     777 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_dummy_data_param()) {</span>
<span class="lineNum">     778 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_dummy_data_param()-&gt;CopyFrom(</span>
<span class="lineNum">     779 </span><span class="lineNoCov">          0 :         v1_layer_param.dummy_data_param());</span>
<span class="lineNum">     780 </span>            :   }
<span class="lineNum">     781 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_eltwise_param()) {</span>
<span class="lineNum">     782 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_eltwise_param()-&gt;CopyFrom(</span>
<span class="lineNum">     783 </span><span class="lineNoCov">          0 :         v1_layer_param.eltwise_param());</span>
<span class="lineNum">     784 </span>            :   }
<span class="lineNum">     785 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_exp_param()) {</span>
<span class="lineNum">     786 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_exp_param()-&gt;CopyFrom(</span>
<span class="lineNum">     787 </span><span class="lineNoCov">          0 :         v1_layer_param.exp_param());</span>
<span class="lineNum">     788 </span>            :   }
<span class="lineNum">     789 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_hdf5_data_param()) {</span>
<span class="lineNum">     790 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_hdf5_data_param()-&gt;CopyFrom(</span>
<span class="lineNum">     791 </span><span class="lineNoCov">          0 :         v1_layer_param.hdf5_data_param());</span>
<span class="lineNum">     792 </span>            :   }
<span class="lineNum">     793 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_hdf5_output_param()) {</span>
<span class="lineNum">     794 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_hdf5_output_param()-&gt;CopyFrom(</span>
<span class="lineNum">     795 </span><span class="lineNoCov">          0 :         v1_layer_param.hdf5_output_param());</span>
<span class="lineNum">     796 </span>            :   }
<span class="lineNum">     797 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_hinge_loss_param()) {</span>
<span class="lineNum">     798 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_hinge_loss_param()-&gt;CopyFrom(</span>
<span class="lineNum">     799 </span><span class="lineNoCov">          0 :         v1_layer_param.hinge_loss_param());</span>
<span class="lineNum">     800 </span>            :   }
<span class="lineNum">     801 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_image_data_param()) {</span>
<span class="lineNum">     802 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_image_data_param()-&gt;CopyFrom(</span>
<span class="lineNum">     803 </span><span class="lineNoCov">          0 :         v1_layer_param.image_data_param());</span>
<span class="lineNum">     804 </span>            :   }
<span class="lineNum">     805 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_infogain_loss_param()) {</span>
<span class="lineNum">     806 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_infogain_loss_param()-&gt;CopyFrom(</span>
<span class="lineNum">     807 </span><span class="lineNoCov">          0 :         v1_layer_param.infogain_loss_param());</span>
<span class="lineNum">     808 </span>            :   }
<span class="lineNum">     809 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_inner_product_param()) {</span>
<span class="lineNum">     810 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_inner_product_param()-&gt;CopyFrom(</span>
<span class="lineNum">     811 </span><span class="lineNoCov">          0 :         v1_layer_param.inner_product_param());</span>
<span class="lineNum">     812 </span>            :   }
<span class="lineNum">     813 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_lrn_param()) {</span>
<span class="lineNum">     814 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_lrn_param()-&gt;CopyFrom(</span>
<span class="lineNum">     815 </span><span class="lineNoCov">          0 :         v1_layer_param.lrn_param());</span>
<span class="lineNum">     816 </span>            :   }
<span class="lineNum">     817 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_memory_data_param()) {</span>
<span class="lineNum">     818 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_memory_data_param()-&gt;CopyFrom(</span>
<span class="lineNum">     819 </span><span class="lineNoCov">          0 :         v1_layer_param.memory_data_param());</span>
<span class="lineNum">     820 </span>            :   }
<span class="lineNum">     821 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_mvn_param()) {</span>
<span class="lineNum">     822 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_mvn_param()-&gt;CopyFrom(</span>
<span class="lineNum">     823 </span><span class="lineNoCov">          0 :         v1_layer_param.mvn_param());</span>
<span class="lineNum">     824 </span>            :   }
<span class="lineNum">     825 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_pooling_param()) {</span>
<span class="lineNum">     826 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_pooling_param()-&gt;CopyFrom(</span>
<span class="lineNum">     827 </span><span class="lineNoCov">          0 :         v1_layer_param.pooling_param());</span>
<span class="lineNum">     828 </span>            :   }
<span class="lineNum">     829 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_power_param()) {</span>
<span class="lineNum">     830 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_power_param()-&gt;CopyFrom(</span>
<span class="lineNum">     831 </span><span class="lineNoCov">          0 :         v1_layer_param.power_param());</span>
<span class="lineNum">     832 </span>            :   }
<span class="lineNum">     833 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_relu_param()) {</span>
<span class="lineNum">     834 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_relu_param()-&gt;CopyFrom(</span>
<span class="lineNum">     835 </span><span class="lineNoCov">          0 :         v1_layer_param.relu_param());</span>
<span class="lineNum">     836 </span>            :   }
<span class="lineNum">     837 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_sigmoid_param()) {</span>
<span class="lineNum">     838 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_sigmoid_param()-&gt;CopyFrom(</span>
<span class="lineNum">     839 </span><span class="lineNoCov">          0 :         v1_layer_param.sigmoid_param());</span>
<span class="lineNum">     840 </span>            :   }
<span class="lineNum">     841 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_softmax_param()) {</span>
<span class="lineNum">     842 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_softmax_param()-&gt;CopyFrom(</span>
<span class="lineNum">     843 </span><span class="lineNoCov">          0 :         v1_layer_param.softmax_param());</span>
<span class="lineNum">     844 </span>            :   }
<span class="lineNum">     845 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_slice_param()) {</span>
<span class="lineNum">     846 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_slice_param()-&gt;CopyFrom(</span>
<span class="lineNum">     847 </span><span class="lineNoCov">          0 :         v1_layer_param.slice_param());</span>
<span class="lineNum">     848 </span>            :   }
<span class="lineNum">     849 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_tanh_param()) {</span>
<span class="lineNum">     850 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_tanh_param()-&gt;CopyFrom(</span>
<span class="lineNum">     851 </span><span class="lineNoCov">          0 :         v1_layer_param.tanh_param());</span>
<span class="lineNum">     852 </span>            :   }
<span class="lineNum">     853 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_threshold_param()) {</span>
<span class="lineNum">     854 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_threshold_param()-&gt;CopyFrom(</span>
<span class="lineNum">     855 </span><span class="lineNoCov">          0 :         v1_layer_param.threshold_param());</span>
<span class="lineNum">     856 </span>            :   }
<span class="lineNum">     857 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_window_data_param()) {</span>
<span class="lineNum">     858 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_window_data_param()-&gt;CopyFrom(</span>
<span class="lineNum">     859 </span><span class="lineNoCov">          0 :         v1_layer_param.window_data_param());</span>
<span class="lineNum">     860 </span>            :   }
<span class="lineNum">     861 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_transform_param()) {</span>
<span class="lineNum">     862 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_transform_param()-&gt;CopyFrom(</span>
<span class="lineNum">     863 </span><span class="lineNoCov">          0 :         v1_layer_param.transform_param());</span>
<span class="lineNum">     864 </span>            :   }
<span class="lineNum">     865 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_loss_param()) {</span>
<span class="lineNum">     866 </span><span class="lineNoCov">          0 :     layer_param-&gt;mutable_loss_param()-&gt;CopyFrom(</span>
<span class="lineNum">     867 </span><span class="lineNoCov">          0 :         v1_layer_param.loss_param());</span>
<span class="lineNum">     868 </span>            :   }
<span class="lineNum">     869 </span><span class="lineNoCov">          0 :   if (v1_layer_param.has_layer()) {</span>
<span class="lineNum">     870 </span><span class="lineNoCov">          0 :     LOG(ERROR) &lt;&lt; &quot;Input NetParameter has V0 layer -- ignoring.&quot;;</span>
<span class="lineNum">     871 </span>            :     is_fully_compatible = false;
<span class="lineNum">     872 </span>            :   }
<span class="lineNum">     873 </span><span class="lineNoCov">          0 :   return is_fully_compatible;</span>
<a name="874"><span class="lineNum">     874 </span>            : }</a>
<span class="lineNum">     875 </span>            : 
<span class="lineNum">     876 </span><span class="lineNoCov">          0 : const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type) {</span>
<span class="lineNum">     877 </span><span class="lineNoCov">          0 :   switch (type) {</span>
<span class="lineNum">     878 </span>            :   case V1LayerParameter_LayerType_NONE:
<span class="lineNum">     879 </span>            :     return &quot;&quot;;
<span class="lineNum">     880 </span>            :   case V1LayerParameter_LayerType_ABSVAL:
<span class="lineNum">     881 </span><span class="lineNoCov">          0 :     return &quot;AbsVal&quot;;</span>
<span class="lineNum">     882 </span>            :   case V1LayerParameter_LayerType_ACCURACY:
<span class="lineNum">     883 </span><span class="lineNoCov">          0 :     return &quot;Accuracy&quot;;</span>
<span class="lineNum">     884 </span>            :   case V1LayerParameter_LayerType_ARGMAX:
<span class="lineNum">     885 </span><span class="lineNoCov">          0 :     return &quot;ArgMax&quot;;</span>
<span class="lineNum">     886 </span>            :   case V1LayerParameter_LayerType_BNLL:
<span class="lineNum">     887 </span><span class="lineNoCov">          0 :     return &quot;BNLL&quot;;</span>
<span class="lineNum">     888 </span>            :   case V1LayerParameter_LayerType_CONCAT:
<span class="lineNum">     889 </span><span class="lineNoCov">          0 :     return &quot;Concat&quot;;</span>
<span class="lineNum">     890 </span>            :   case V1LayerParameter_LayerType_CONTRASTIVE_LOSS:
<span class="lineNum">     891 </span><span class="lineNoCov">          0 :     return &quot;ContrastiveLoss&quot;;</span>
<span class="lineNum">     892 </span>            :   case V1LayerParameter_LayerType_CONVOLUTION:
<span class="lineNum">     893 </span><span class="lineNoCov">          0 :     return &quot;Convolution&quot;;</span>
<span class="lineNum">     894 </span>            :   case V1LayerParameter_LayerType_DECONVOLUTION:
<span class="lineNum">     895 </span><span class="lineNoCov">          0 :     return &quot;Deconvolution&quot;;</span>
<span class="lineNum">     896 </span>            :   case V1LayerParameter_LayerType_DATA:
<span class="lineNum">     897 </span><span class="lineNoCov">          0 :     return &quot;Data&quot;;</span>
<span class="lineNum">     898 </span>            :   case V1LayerParameter_LayerType_DROPOUT:
<span class="lineNum">     899 </span><span class="lineNoCov">          0 :     return &quot;Dropout&quot;;</span>
<span class="lineNum">     900 </span>            :   case V1LayerParameter_LayerType_DUMMY_DATA:
<span class="lineNum">     901 </span><span class="lineNoCov">          0 :     return &quot;DummyData&quot;;</span>
<span class="lineNum">     902 </span>            :   case V1LayerParameter_LayerType_EUCLIDEAN_LOSS:
<span class="lineNum">     903 </span><span class="lineNoCov">          0 :     return &quot;EuclideanLoss&quot;;</span>
<span class="lineNum">     904 </span>            :   case V1LayerParameter_LayerType_ELTWISE:
<span class="lineNum">     905 </span><span class="lineNoCov">          0 :     return &quot;Eltwise&quot;;</span>
<span class="lineNum">     906 </span>            :   case V1LayerParameter_LayerType_EXP:
<span class="lineNum">     907 </span><span class="lineNoCov">          0 :     return &quot;Exp&quot;;</span>
<span class="lineNum">     908 </span>            :   case V1LayerParameter_LayerType_FLATTEN:
<span class="lineNum">     909 </span><span class="lineNoCov">          0 :     return &quot;Flatten&quot;;</span>
<span class="lineNum">     910 </span>            :   case V1LayerParameter_LayerType_HDF5_DATA:
<span class="lineNum">     911 </span><span class="lineNoCov">          0 :     return &quot;HDF5Data&quot;;</span>
<span class="lineNum">     912 </span>            :   case V1LayerParameter_LayerType_HDF5_OUTPUT:
<span class="lineNum">     913 </span><span class="lineNoCov">          0 :     return &quot;HDF5Output&quot;;</span>
<span class="lineNum">     914 </span>            :   case V1LayerParameter_LayerType_HINGE_LOSS:
<span class="lineNum">     915 </span><span class="lineNoCov">          0 :     return &quot;HingeLoss&quot;;</span>
<span class="lineNum">     916 </span>            :   case V1LayerParameter_LayerType_IM2COL:
<span class="lineNum">     917 </span><span class="lineNoCov">          0 :     return &quot;Im2col&quot;;</span>
<span class="lineNum">     918 </span>            :   case V1LayerParameter_LayerType_IMAGE_DATA:
<span class="lineNum">     919 </span><span class="lineNoCov">          0 :     return &quot;ImageData&quot;;</span>
<span class="lineNum">     920 </span>            :   case V1LayerParameter_LayerType_INFOGAIN_LOSS:
<span class="lineNum">     921 </span><span class="lineNoCov">          0 :     return &quot;InfogainLoss&quot;;</span>
<span class="lineNum">     922 </span>            :   case V1LayerParameter_LayerType_INNER_PRODUCT:
<span class="lineNum">     923 </span><span class="lineNoCov">          0 :     return &quot;InnerProduct&quot;;</span>
<span class="lineNum">     924 </span>            :   case V1LayerParameter_LayerType_LRN:
<span class="lineNum">     925 </span><span class="lineNoCov">          0 :     return &quot;LRN&quot;;</span>
<span class="lineNum">     926 </span>            :   case V1LayerParameter_LayerType_MEMORY_DATA:
<span class="lineNum">     927 </span><span class="lineNoCov">          0 :     return &quot;MemoryData&quot;;</span>
<span class="lineNum">     928 </span>            :   case V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS:
<span class="lineNum">     929 </span><span class="lineNoCov">          0 :     return &quot;MultinomialLogisticLoss&quot;;</span>
<span class="lineNum">     930 </span>            :   case V1LayerParameter_LayerType_MVN:
<span class="lineNum">     931 </span><span class="lineNoCov">          0 :     return &quot;MVN&quot;;</span>
<span class="lineNum">     932 </span>            :   case V1LayerParameter_LayerType_POOLING:
<span class="lineNum">     933 </span><span class="lineNoCov">          0 :     return &quot;Pooling&quot;;</span>
<span class="lineNum">     934 </span>            :   case V1LayerParameter_LayerType_POWER:
<span class="lineNum">     935 </span><span class="lineNoCov">          0 :     return &quot;Power&quot;;</span>
<span class="lineNum">     936 </span>            :   case V1LayerParameter_LayerType_RELU:
<span class="lineNum">     937 </span><span class="lineNoCov">          0 :     return &quot;ReLU&quot;;</span>
<span class="lineNum">     938 </span>            :   case V1LayerParameter_LayerType_SIGMOID:
<span class="lineNum">     939 </span><span class="lineNoCov">          0 :     return &quot;Sigmoid&quot;;</span>
<span class="lineNum">     940 </span>            :   case V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS:
<span class="lineNum">     941 </span><span class="lineNoCov">          0 :     return &quot;SigmoidCrossEntropyLoss&quot;;</span>
<span class="lineNum">     942 </span>            :   case V1LayerParameter_LayerType_SILENCE:
<span class="lineNum">     943 </span><span class="lineNoCov">          0 :     return &quot;Silence&quot;;</span>
<span class="lineNum">     944 </span>            :   case V1LayerParameter_LayerType_SOFTMAX:
<span class="lineNum">     945 </span><span class="lineNoCov">          0 :     return &quot;Softmax&quot;;</span>
<span class="lineNum">     946 </span>            :   case V1LayerParameter_LayerType_SOFTMAX_LOSS:
<span class="lineNum">     947 </span><span class="lineNoCov">          0 :     return &quot;SoftmaxWithLoss&quot;;</span>
<span class="lineNum">     948 </span>            :   case V1LayerParameter_LayerType_SPLIT:
<span class="lineNum">     949 </span><span class="lineNoCov">          0 :     return &quot;Split&quot;;</span>
<span class="lineNum">     950 </span>            :   case V1LayerParameter_LayerType_SLICE:
<span class="lineNum">     951 </span><span class="lineNoCov">          0 :     return &quot;Slice&quot;;</span>
<span class="lineNum">     952 </span>            :   case V1LayerParameter_LayerType_TANH:
<span class="lineNum">     953 </span><span class="lineNoCov">          0 :     return &quot;TanH&quot;;</span>
<span class="lineNum">     954 </span>            :   case V1LayerParameter_LayerType_WINDOW_DATA:
<span class="lineNum">     955 </span><span class="lineNoCov">          0 :     return &quot;WindowData&quot;;</span>
<span class="lineNum">     956 </span>            :   case V1LayerParameter_LayerType_THRESHOLD:
<span class="lineNum">     957 </span><span class="lineNoCov">          0 :     return &quot;Threshold&quot;;</span>
<span class="lineNum">     958 </span>            :   default:
<span class="lineNum">     959 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Unknown V1LayerParameter layer type: &quot; &lt;&lt; type;</span>
<span class="lineNum">     960 </span>            :     return &quot;&quot;;
<span class="lineNum">     961 </span>            :   }
<a name="962"><span class="lineNum">     962 </span>            : }</a>
<span class="lineNum">     963 </span>            : 
<span class="lineNum">     964 </span><span class="lineCov">          2 : bool NetNeedsInputUpgrade(const NetParameter&amp; net_param) {</span>
<span class="lineNum">     965 </span><span class="lineCov">          2 :   return net_param.input_size() &gt; 0;</span>
<span class="lineNum">     966 </span>            : }
<span class="lineNum">     967 </span>            : 
<span class="lineNum">     968 </span><span class="lineNoCov">          0 : void UpgradeNetInput(NetParameter* net_param) {</span>
<span class="lineNum">     969 </span>            :   // Collect inputs and convert to Input layer definitions.
<span class="lineNum">     970 </span>            :   // If the NetParameter holds an input alone, without shape/dim, then
<span class="lineNum">     971 </span>            :   // it's a legacy caffemodel and simply stripping the input field is enough.
<span class="lineNum">     972 </span><span class="lineNoCov">          0 :   bool has_shape = net_param-&gt;input_shape_size() &gt; 0;</span>
<span class="lineNum">     973 </span><span class="lineNoCov">          0 :   bool has_dim = net_param-&gt;input_dim_size() &gt; 0;</span>
<span class="lineNum">     974 </span><span class="lineNoCov">          0 :   if (has_shape || has_dim) {</span>
<span class="lineNum">     975 </span>            :     LayerParameter* layer_param = net_param-&gt;add_layer();
<span class="lineNum">     976 </span><span class="lineNoCov">          0 :     layer_param-&gt;set_name(&quot;input&quot;);</span>
<span class="lineNum">     977 </span><span class="lineNoCov">          0 :     layer_param-&gt;set_type(&quot;Input&quot;);</span>
<span class="lineNum">     978 </span><span class="lineNoCov">          0 :     InputParameter* input_param = layer_param-&gt;mutable_input_param();</span>
<span class="lineNum">     979 </span>            :     // Convert input fields into a layer.
<span class="lineNum">     980 </span><span class="lineNoCov">          0 :     for (int i = 0; i &lt; net_param-&gt;input_size(); ++i) {</span>
<span class="lineNum">     981 </span>            :       layer_param-&gt;add_top(net_param-&gt;input(i));
<span class="lineNum">     982 </span><span class="lineNoCov">          0 :       if (has_shape) {</span>
<span class="lineNum">     983 </span><span class="lineNoCov">          0 :         input_param-&gt;add_shape()-&gt;CopyFrom(net_param-&gt;input_shape(i));</span>
<span class="lineNum">     984 </span>            :       } else {
<span class="lineNum">     985 </span>            :         // Turn legacy input dimensions into shape.
<span class="lineNum">     986 </span>            :         BlobShape* shape = input_param-&gt;add_shape();
<span class="lineNum">     987 </span><span class="lineNoCov">          0 :         int first_dim = i*4;</span>
<span class="lineNum">     988 </span><span class="lineNoCov">          0 :         int last_dim = first_dim + 4;</span>
<span class="lineNum">     989 </span><span class="lineNoCov">          0 :         for (int j = first_dim; j &lt; last_dim; j++) {</span>
<span class="lineNum">     990 </span><span class="lineNoCov">          0 :           shape-&gt;add_dim(net_param-&gt;input_dim(j));</span>
<span class="lineNum">     991 </span>            :         }
<span class="lineNum">     992 </span>            :       }
<span class="lineNum">     993 </span>            :     }
<span class="lineNum">     994 </span>            :     // Swap input layer to beginning of net to satisfy layer dependencies.
<span class="lineNum">     995 </span><span class="lineNoCov">          0 :     for (int i = net_param-&gt;layer_size() - 1; i &gt; 0; --i) {</span>
<span class="lineNum">     996 </span><span class="lineNoCov">          0 :       net_param-&gt;mutable_layer(i-1)-&gt;Swap(net_param-&gt;mutable_layer(i));</span>
<span class="lineNum">     997 </span>            :     }
<span class="lineNum">     998 </span>            :   }
<span class="lineNum">     999 </span>            :   // Clear inputs.
<span class="lineNum">    1000 </span>            :   net_param-&gt;clear_input();
<span class="lineNum">    1001 </span>            :   net_param-&gt;clear_input_shape();
<span class="lineNum">    1002 </span>            :   net_param-&gt;clear_input_dim();
<a name="1003"><span class="lineNum">    1003 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    1004 </span>            : 
<span class="lineNum">    1005 </span><span class="lineCov">          2 : bool NetNeedsBatchNormUpgrade(const NetParameter&amp; net_param) {</span>
<span class="lineNum">    1006 </span><span class="lineCov">         46 :   for (int i = 0; i &lt; net_param.layer_size(); ++i) {</span>
<span class="lineNum">    1007 </span>            :     // Check if BatchNorm layers declare three parameters, as required by
<span class="lineNum">    1008 </span>            :     // the previous BatchNorm layer definition.
<span class="lineNum">    1009 </span><span class="lineCov">         22 :     if (net_param.layer(i).type() == &quot;BatchNorm&quot;</span>
<span class="lineNum">    1010 </span><span class="lineCov">         22 :         &amp;&amp; net_param.layer(i).param_size() == 3) {</span>
<span class="lineNum">    1011 </span>            :       return true;
<span class="lineNum">    1012 </span>            :     }
<span class="lineNum">    1013 </span>            :   }
<span class="lineNum">    1014 </span>            :   return false;
<span class="lineNum">    1015 </span>            : }
<span class="lineNum">    1016 </span>            : 
<span class="lineNum">    1017 </span><span class="lineNoCov">          0 : void UpgradeNetBatchNorm(NetParameter* net_param) {</span>
<span class="lineNum">    1018 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; net_param-&gt;layer_size(); ++i) {</span>
<span class="lineNum">    1019 </span>            :     // Check if BatchNorm layers declare three parameters, as required by
<span class="lineNum">    1020 </span>            :     // the previous BatchNorm layer definition.
<span class="lineNum">    1021 </span><span class="lineNoCov">          0 :     if (net_param-&gt;layer(i).type() == &quot;BatchNorm&quot;</span>
<span class="lineNum">    1022 </span><span class="lineNoCov">          0 :         &amp;&amp; net_param-&gt;layer(i).param_size() == 3) {</span>
<span class="lineNum">    1023 </span>            :       // set lr_mult and decay_mult to zero. leave all other param intact.
<span class="lineNum">    1024 </span><span class="lineNoCov">          0 :       for (int ip = 0; ip &lt; net_param-&gt;layer(i).param_size(); ip++) {</span>
<span class="lineNum">    1025 </span>            :         ParamSpec* fixed_param_spec =
<span class="lineNum">    1026 </span>            :           net_param-&gt;mutable_layer(i)-&gt;mutable_param(ip);
<span class="lineNum">    1027 </span>            :         fixed_param_spec-&gt;set_lr_mult(0.f);
<span class="lineNum">    1028 </span>            :         fixed_param_spec-&gt;set_decay_mult(0.f);
<span class="lineNum">    1029 </span>            :       }
<span class="lineNum">    1030 </span>            :     }
<span class="lineNum">    1031 </span>            :   }
<span class="lineNum">    1032 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1033 </span>            : 
<span class="lineNum">    1034 </span>            : // Return true iff the solver contains any old solver_type specified as enums
<span class="lineNum">    1035 </span><span class="lineCov">          1 : bool SolverNeedsTypeUpgrade(const SolverParameter&amp; solver_param) {</span>
<span class="lineNum">    1036 </span><span class="lineCov">          1 :   if (solver_param.has_solver_type()) {</span>
<span class="lineNum">    1037 </span>            :     return true;
<span class="lineNum">    1038 </span>            :   }
<span class="lineNum">    1039 </span><span class="lineCov">          1 :   return false;</span>
<span class="lineNum">    1040 </span>            : }
<span class="lineNum">    1041 </span>            : 
<span class="lineNum">    1042 </span><span class="lineNoCov">          0 : bool UpgradeSolverType(SolverParameter* solver_param) {</span>
<span class="lineNum">    1043 </span><span class="lineNoCov">          0 :   CHECK(!solver_param-&gt;has_solver_type() || !solver_param-&gt;has_type())</span>
<span class="lineNum">    1044 </span>            :       &lt;&lt; &quot;Failed to upgrade solver: old solver_type field (enum) and new type &quot;
<span class="lineNum">    1045 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;field (string) cannot be both specified in solver proto text.&quot;;</span>
<span class="lineNum">    1046 </span><span class="lineNoCov">          0 :   if (solver_param-&gt;has_solver_type()) {</span>
<span class="lineNum">    1047 </span>            :     string type;
<span class="lineNum">    1048 </span><span class="lineNoCov">          0 :     switch (solver_param-&gt;solver_type()) {</span>
<span class="lineNum">    1049 </span>            :     case SolverParameter_SolverType_SGD:
<span class="lineNum">    1050 </span>            :       type = &quot;SGD&quot;;
<span class="lineNum">    1051 </span>            :       break;
<span class="lineNum">    1052 </span>            :     case SolverParameter_SolverType_NESTEROV:
<span class="lineNum">    1053 </span>            :       type = &quot;Nesterov&quot;;
<span class="lineNum">    1054 </span>            :       break;
<span class="lineNum">    1055 </span>            :     case SolverParameter_SolverType_ADAGRAD:
<span class="lineNum">    1056 </span>            :       type = &quot;AdaGrad&quot;;
<span class="lineNum">    1057 </span>            :       break;
<span class="lineNum">    1058 </span>            :     case SolverParameter_SolverType_RMSPROP:
<span class="lineNum">    1059 </span>            :       type = &quot;RMSProp&quot;;
<span class="lineNum">    1060 </span>            :       break;
<span class="lineNum">    1061 </span>            :     case SolverParameter_SolverType_ADADELTA:
<span class="lineNum">    1062 </span>            :       type = &quot;AdaDelta&quot;;
<span class="lineNum">    1063 </span>            :       break;
<span class="lineNum">    1064 </span>            :     case SolverParameter_SolverType_ADAM:
<span class="lineNum">    1065 </span>            :       type = &quot;Adam&quot;;
<span class="lineNum">    1066 </span>            :       break;
<span class="lineNum">    1067 </span>            :     default:
<span class="lineNum">    1068 </span><span class="lineNoCov">          0 :       LOG(FATAL) &lt;&lt; &quot;Unknown SolverParameter solver_type: &quot; &lt;&lt; type;</span>
<span class="lineNum">    1069 </span>            :     }
<span class="lineNum">    1070 </span><span class="lineNoCov">          0 :     solver_param-&gt;set_type(type);</span>
<span class="lineNum">    1071 </span>            :     solver_param-&gt;clear_solver_type();
<span class="lineNum">    1072 </span>            :   } else {
<span class="lineNum">    1073 </span><span class="lineNoCov">          0 :     LOG(ERROR) &lt;&lt; &quot;Warning: solver type already up to date. &quot;;</span>
<span class="lineNum">    1074 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    1075 </span>            :   }
<span class="lineNum">    1076 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">    1077 </span>            : }
<a name="1078"><span class="lineNum">    1078 </span>            : </a>
<span class="lineNum">    1079 </span>            : // Check for deprecations and upgrade the SolverParameter as needed.
<span class="lineNum">    1080 </span><span class="lineCov">          1 : bool UpgradeSolverAsNeeded(const string&amp; param_file, SolverParameter* param) {</span>
<span class="lineNum">    1081 </span>            :   bool success = true;
<span class="lineNum">    1082 </span>            :   // Try to upgrade old style solver_type enum fields into new string type
<span class="lineNum">    1083 </span><span class="lineCov">          1 :   if (SolverNeedsTypeUpgrade(*param)) {</span>
<span class="lineNum">    1084 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;Attempting to upgrade input file specified using deprecated &quot;</span>
<span class="lineNum">    1085 </span>            :               &lt;&lt; &quot;'solver_type' field (enum)': &quot; &lt;&lt; param_file;
<span class="lineNum">    1086 </span><span class="lineNoCov">          0 :     if (!UpgradeSolverType(param)) {</span>
<span class="lineNum">    1087 </span>            :       success = false;
<span class="lineNum">    1088 </span><span class="lineNoCov">          0 :       LOG(ERROR) &lt;&lt; &quot;Warning: had one or more problems upgrading &quot;</span>
<span class="lineNum">    1089 </span><span class="lineNoCov">          0 :                  &lt;&lt; &quot;SolverType (see above).&quot;;</span>
<span class="lineNum">    1090 </span>            :     } else {
<span class="lineNum">    1091 </span><span class="lineNoCov">          0 :       LOG(INFO) &lt;&lt; &quot;Successfully upgraded file specified using deprecated &quot;</span>
<span class="lineNum">    1092 </span><span class="lineNoCov">          0 :                 &lt;&lt; &quot;'solver_type' field (enum) to 'type' field (string).&quot;;</span>
<span class="lineNum">    1093 </span><span class="lineNoCov">          0 :       LOG(WARNING) &lt;&lt; &quot;Note that future Caffe releases will only support &quot;</span>
<span class="lineNum">    1094 </span><span class="lineNoCov">          0 :                    &lt;&lt; &quot;'type' field (string) for a solver's type.&quot;;</span>
<span class="lineNum">    1095 </span>            :     }
<span class="lineNum">    1096 </span>            :   }
<span class="lineNum">    1097 </span><span class="lineCov">          1 :   return success;</span>
<span class="lineNum">    1098 </span>            : }
<span class="lineNum">    1099 </span>            : 
<span class="lineNum">    1100 </span>            : // Replaces snapshot_prefix of SolverParameter if it is not specified
<span class="lineNum">    1101 </span>            : // or is set to directory
<span class="lineNum">    1102 </span><span class="lineCov">          1 : void UpgradeSnapshotPrefixProperty(const string&amp; param_file,</span>
<span class="lineNum">    1103 </span>            :                                    SolverParameter* param) {
<span class="lineNum">    1104 </span>            :   using boost::filesystem::path;
<span class="lineNum">    1105 </span>            :   using boost::filesystem::is_directory;
<span class="lineNum">    1106 </span><span class="lineCov">          1 :   if (!param-&gt;has_snapshot_prefix()) {</span>
<span class="lineNum">    1107 </span><span class="lineNoCov">          0 :     param-&gt;set_snapshot_prefix(path(param_file).replace_extension().string());</span>
<span class="lineNum">    1108 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;snapshot_prefix was not specified and is set to &quot;</span>
<span class="lineNum">    1109 </span><span class="lineNoCov">          0 :                 + param-&gt;snapshot_prefix();</span>
<span class="lineNum">    1110 </span><span class="lineCov">          1 :   } else if (is_directory(param-&gt;snapshot_prefix())) {</span>
<span class="lineNum">    1111 </span><span class="lineNoCov">          0 :     param-&gt;set_snapshot_prefix((path(param-&gt;snapshot_prefix()) /</span>
<span class="lineNum">    1112 </span><span class="lineNoCov">          0 :                                path(param_file).stem()).string());</span>
<span class="lineNum">    1113 </span><span class="lineNoCov">          0 :     LOG(INFO) &lt;&lt; &quot;snapshot_prefix was a directory and is replaced to &quot;</span>
<span class="lineNum">    1114 </span><span class="lineNoCov">          0 :                 + param-&gt;snapshot_prefix();</span>
<span class="lineNum">    1115 </span>            :   }
<span class="lineNum">    1116 </span><span class="lineCov">          1 : }</span>
<a name="1117"><span class="lineNum">    1117 </span>            : </a>
<span class="lineNum">    1118 </span>            : // Read parameters from a file into a SolverParameter proto message.
<span class="lineNum">    1119 </span><span class="lineCov">          1 : void ReadSolverParamsFromTextFileOrDie(const string&amp; param_file,</span>
<span class="lineNum">    1120 </span>            :                                        SolverParameter* param) {
<span class="lineNum">    1121 </span><span class="lineCov">          2 :   CHECK(ReadProtoFromTextFile(param_file, param))</span>
<span class="lineNum">    1122 </span><span class="lineCov">          2 :       &lt;&lt; &quot;Failed to parse SolverParameter file: &quot; &lt;&lt; param_file;</span>
<span class="lineNum">    1123 </span><span class="lineCov">          1 :   UpgradeSolverAsNeeded(param_file, param);</span>
<span class="lineNum">    1124 </span><span class="lineCov">          1 :   UpgradeSnapshotPrefixProperty(param_file, param);</span>
<a name="1125"><span class="lineNum">    1125 </span><span class="lineCov">          1 : }</span></a>
<span class="lineNum">    1126 </span>            : 
<span class="lineNum">    1127 </span><span class="lineCov">          3 : }  // namespace caffe</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
